In one of my last posts, I posted a code snippet which demonstrated how to use php to expand short URLs to their original long form. Here’s the Python version I coded a few minutes ago.
Python 3:
1 2 3 4 5 6 7 8 9 |
import http.client from urllib.parse import urlparse url = input("\nEnter URL:\n>>>").strip() t = urlparse(url) print("\n-----Connecting-----\n\n") conn = http.client.HTTPConnection(t.netloc) conn.request("GET", t.path) print(conn.getresponse().getheader("Location")) print("\n\n"); |
These codes are for Python 3. The tool was developed for CLI use.