![]() |
Submitting POST data
Okay, so using urllib2 I can send GET data easily to a website like so:
:
import urllib2But how do you suppose I sent POST data to a website? I need this so I can login to a website using an automated script. Will urllib2 store your session as if you're browing directly on the site, or is there some fancy thing I need to do for that? :o |
I believe you would use the optional data parameter.
|
As Dameon said, pass the POST data as the second parameter to urlopen. You can either construct the POST query string by yourself, or use urllib.urlencode to construct the query string from you from a dictionary, e.g
:
p = urllib.urlopen("http://foo.com/", urllib.urlencode({"foo" : "bar", "bar" : "baz"}))Quote:
|
Oooh! Pretty!! ^^;;
The cookie thing will need some experimentin' with though. Thanks. |
| All times are GMT -5. The time now is 6:28 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC