Created
July 22, 2018 23:35
-
-
Save WJDigby/3755789611952bed66cdbc85eb702060 to your computer and use it in GitHub Desktop.
URL Lengthener
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 | |
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