Created
April 11, 2015 15:05
-
-
Save Averroes/3ba07fd69d4f39a9e316 to your computer and use it in GitHub Desktop.
urllib2 http get args
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
#!/usr/bin/env python | |
# encoding: utf-8 | |
# | |
# Copyright (c) 2008 Doug Hellmann All rights reserved. | |
# | |
""" | |
""" | |
#end_pymotw_header | |
import urllib | |
import urllib2 | |
query_args = { 'q':'query string', 'foo':'bar' } | |
encoded_args = urllib.urlencode(query_args) | |
print 'Encoded:', encoded_args | |
url = 'http://localhost:8080/?' + encoded_args | |
print urllib2.urlopen(url).read() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment