Created
May 16, 2023 04:15
-
-
Save ruo91/2088249e9b3fa60dbc870e7eb2fd5496 to your computer and use it in GitHub Desktop.
Python3 - URL Decode
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
# - Usage | |
# ex1) | |
# python3 url_decode.py "Blah%7E%20Blah%7E~" | |
# | |
# ex2) | |
# python3 url_decode.py "/path/to/directory/example-url-encode.txt" | |
# | |
# - RefURL | |
# https://gist.github.com/Paradoxis/733af9516af9022d2d4ca7432ff15a96 | |
# | |
#!/usr/bin/env python3 | |
from argparse import ArgumentParser | |
from sys import stdin, stdout | |
from urllib.parse import unquote as url_decode | |
if __name__ == "__main__": | |
parser = ArgumentParser() | |
parser.add_argument("string", nargs="*") | |
args = parser.parse_args() | |
if args.string: | |
print(url_decode(" ".join(args.string)), end='\n') | |
else: | |
print(url_decode(stdin.read()[:-1]), end='\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment