Last active
June 11, 2016 14:07
-
-
Save rugk/3ea35d04d66c2295e02d0b6cb6d822a2 to your computer and use it in GitHub Desktop.
Python url download test
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
#!/usr/bin/env python | |
# LICENSE: CC0/Public Domain - To the extent possible under law, rugk has waived all copyright and related or neighboring rights to this work. This work is published from: Deutschland. | |
import sys | |
try: | |
from urllib.request import urlopen # Python 3 | |
except ImportError: | |
from urllib2 import urlopen # Python 2 | |
testurl = "https://..." | |
if len(sys.argv) >= 2: | |
testurl = sys.argv[1] | |
print "Accessing " + testurl + "..." | |
resp = urlopen(testurl) | |
respdata = resp.read() | |
print "RAW:" | |
print respdata | |
resp_data = respdata.decode('utf8').strip() | |
print "\nDecoded:" | |
print resp_data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment