Skip to content

Commit b370a01

Browse files
authored
Merge pull request Astrodevil#346 from leeveshkamboj/main
Create urlshortner.py
2 parents 5dfdcdb + 99f1276 commit b370a01

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Python/urlshortner.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import urllib
2+
import requests
3+
import json
4+
5+
6+
def shorten(link):
7+
key = '' # Your cutt.ly api key
8+
url = urllib.parse.quote(link)
9+
r = requests.get(f'http://cutt.ly/api/api.php?key={key}&short={url}')
10+
y = json.loads(r.text)
11+
return y['url']['shortLink']
12+
13+
url = input("Enter url you want to shorten=>")
14+
print("Your shortened url:", shorten(url))

0 commit comments

Comments
 (0)