We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fdc27a9 commit 9290d99Copy full SHA for 9290d99
URL Shortener/urlshortener.py
@@ -0,0 +1,17 @@
1
+import requests
2
+
3
+def shorten_url_with_tinyurl(long_url):
4
+ url = f'http://tinyurl.com/api-create.php?url={long_url}'
5
+ response = requests.get(url)
6
+ if response.status_code == 200:
7
+ return response.text
8
+ else:
9
+ return None
10
11
+long_url = r"INSERT YOUR LONG URL HERE"
12
+short_url = shorten_url_with_tinyurl(long_url)
13
14
+if short_url:
15
+ print(f'Shortened URL: {short_url}')
16
+else:
17
+ print('Error shortening URL')
0 commit comments