Last active
November 11, 2022 18:24
-
-
Save 24Ryou/9f2429187454ec59ab0d161d514276b5 to your computer and use it in GitHub Desktop.
make url shorten
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from decouple import config | |
import urllib | |
def shortURL(URL): | |
key = config('CUTTLY_TOKEN') | |
parsedURL = urllib.parse.quote(URL) | |
r = requests.get('http://cutt.ly/api/api.php?key={}&short={}'.format(key, parsedURL)) | |
data = r.json() | |
return data['url']['shortLink'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment