Skip to content

Instantly share code, notes, and snippets.

@Averroes
Created April 11, 2015 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Averroes/3ba07fd69d4f39a9e316 to your computer and use it in GitHub Desktop.
Save Averroes/3ba07fd69d4f39a9e316 to your computer and use it in GitHub Desktop.
urllib2 http get args
#!/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