Skip to content

Commit 2e22e30

Browse files
committed
🎨 URL Shortener
1 parent 1705131 commit 2e22e30

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

requirements.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
11
bitly-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
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
BITLY_ACCESS_TOKEN = "YOUR_ACCESS_TOKEN"
44
ACCESS = 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

77
if __name__ == "__main__":
88
print(f"Short URL = {SHORT_URL['url']}")

url-shortener/cuttly.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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)

0 commit comments

Comments
 (0)