Posted By

atr000 on 05/23/09


Tagged

http post python


Versions (?)

python: urllib2 http post


 / Published in: Python
 

I see almost all GET, so this is handy to have around

  1. #!/usr/bin/python
  2. import urllib,urllib2
  3.  
  4. url = 'http://www.commentcamarche.net/search/search.php3'
  5. parameters = {'Mot' : 'Gimp'}
  6.  
  7. data = urllib.urlencode(parameters) # Use urllib to encode the parameters
  8. request = urllib2.Request(url, data)
  9. response = urllib2.urlopen(request) # This request is sent in HTTP POST
  10. page = response.read(200000)

Report this snippet  

You need to login to post a comment.