File tree Expand file tree Collapse file tree 3 files changed +19
-1
lines changed
Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Original file line number Diff line number Diff line change 11bitly-api == 0.3
2+ certifi == 2021.5.30
3+ chardet == 4.0.0
4+ idna == 2.10
5+ requests == 2.25.1
6+ urllib3 == 1.26.5
Original file line number Diff line number Diff line change 22
33BITLY_ACCESS_TOKEN = "YOUR_ACCESS_TOKEN"
44ACCESS = bitly_api .Connection (access_token = BITLY_ACCESS_TOKEN )
5- SHORT_URL = ACCESS .shorten (str (input ()))
5+ SHORT_URL = ACCESS .shorten (str (input ("Introduce you larger URL: " )))
66
77if __name__ == "__main__" :
88 print (f"Short URL = { SHORT_URL ['url' ]} " )
Original file line number Diff line number Diff line change 1+ import requests
2+
3+ API_KEY = "YOUR_API_KEY"
4+ URL = str (input ("Introduce your larger url: " ))
5+ API_URL = f"https://cutt.ly/api/api.php?key={ API_KEY } &short={ URL } "
6+ DATA = requests .get (API_URL ).json ()["url" ]
7+
8+ if __name__ == "__main__" :
9+ if DATA ["status" ] == 7 :
10+ shortened_url = DATA ["shortLink" ]
11+ print ("Shortened URL:" , shortened_url )
12+ else :
13+ print ("[!] Error Shortening URL:" , DATA )
You can’t perform that action at this time.
0 commit comments