Last active
August 19, 2021 02:45
-
-
Save Greydus/c52d62d3d4b8679a602f2145f9107735 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 argparse | |
| import urllib.parse | |
| import urllib.request | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument('url', metavar='<url>') | |
| parser.add_argument('-d', '--data', metavar='<data>') | |
| cmd_opts = parser.parse_args() | |
| if cmd_opts.data is not None: | |
| d = cmd_opts.data.encode() | |
| else: | |
| d = cmd_opts.data | |
| r = urllib.request.urlopen(cmd_opts.url, data=d) | |
| headers = r.headers.items() | |
| for header in headers: | |
| print(header[0] + ': ' + header[1]) | |
| print('\n' + r.read().decode()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment