Skip to content

Instantly share code, notes, and snippets.

@WJDigby
Created July 22, 2018 23:35
Show Gist options
  • Save WJDigby/3755789611952bed66cdbc85eb702060 to your computer and use it in GitHub Desktop.
Save WJDigby/3755789611952bed66cdbc85eb702060 to your computer and use it in GitHub Desktop.
URL Lengthener
import requests
import argparse
def lengthen(url):
if not url.lower().startswith(("http://", "https://")):
url = "http://" + url
http_req = requests.get(url)
return http_req.url
def main():
parser = argparse.ArgumentParser(description='Given a shortened URL, display the final URL after redirect.')
parser.add_argument('url', metavar='url', help="Shortened URL.")
args = parser.parse_args()
url = args.url
result = lengthen(url)
print("[+] Final URL: " + result)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment