Created
December 23, 2020 15:00
-
-
Save Shurastei/6159a5de29201185db654861defcb458 to your computer and use it in GitHub Desktop.
Encurtar URL
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 | |
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