Skip to content

Instantly share code, notes, and snippets.

@Shurastei
Created December 23, 2020 15:00
Show Gist options
  • Save Shurastei/6159a5de29201185db654861defcb458 to your computer and use it in GitHub Desktop.
Save Shurastei/6159a5de29201185db654861defcb458 to your computer and use it in GitHub Desktop.
Encurtar URL
import requests
api_key = "db495e6f05aacf29d13e7dae7e1c033e728e1"
# URL
url = "https://www.google.com"
# Name
api_url = f"https://cutt.ly/api/api.php?key={api_key}&short={url}"
# ou
# api_url = f"https://cutt.ly/api/api.php?key={api_key}&short={url}&name=some_unique_name"
# Request
data = requests.get(api_url).json()["url"]
if data["status"] == 7:
# shortened URL
shortened_url = data["shortLink"]
print("Shortened URL:", shortened_url)
else:
print("[!] Error Shortening URL:", data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment