Created
September 13, 2011 08:20
-
-
Save lsauer/1213403 to your computer and use it in GitHub Desktop.
Submitting a browser-like HTTP request
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
#L sauer 2011, public domain | |
def main(): | |
import urllib2 | |
furl = urllib2.Request('http://www.mypacm.us.gov/bin/www_bget?one=two') | |
furl.add_header('Referer', 'http://www.mypacm.us.gov/') | |
furl.add_header('User-agent', 'Mozilla/5.0 AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.35 Safari/535.1') | |
furl.add_header('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8') | |
furl.add_header('Accept-Encoding', 'gzip,deflate,sdch') | |
furl.add_header('Accept-Language', 'en-US,en;q=0.8') | |
#furl.add_header('Origin', 'http://www.mypacm.us.gov/bin/') | |
f = urllib2.urlopen(furl) | |
print f.read(100000) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment