By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,767 Members | 1,354 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,767 IT Pros & Developers. It's quick & easy.

fetching a POST webpage...

P: n/a
hi...

i have the basic code to fetcha url/web page. however, i'm trying to fetch a
page that uses a FORM/POST. has anyone done this, i've tried a few times
without success.

i've analyzed the data stream using Firefox/Livehttpheaders to get the HTTP
stream.. but i'm doing something wrong, and can't quite see what the
err/issue is...

if you've done this kind of thing, and you have some thoughts, let me know.
i can send you the output of the livehttpheaders app, and the test code that
i have...

thanks..

-bruce
Jul 7 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a

bruce wrote:
hi...

i have the basic code to fetcha url/web page. however, i'm trying to fetch a
page that uses a FORM/POST. has anyone done this, i've tried a few times
without success.

i've analyzed the data stream using Firefox/Livehttpheaders to get the HTTP
stream.. but i'm doing something wrong, and can't quite see what the
err/issue is...

if you've done this kind of thing, and you have some thoughts, let me know.
i can send you the output of the livehttpheaders app, and the test code that
i have...

thanks..

-bruce
If you read the page and parse the form or already know the values you
need to POST this may help.
>From http://www.python.org/doc/current/li...-examples.html
Here is an example session that shows how to "POST" requests:
>>import httplib, urllib
params = urllib.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0})
headers = {"Content-type": "application/x-www-form-urlencoded",
.... "Accept": "text/plain"}
>>conn = httplib.HTTPConnection("musi-cal.mojam.com:80")
conn.request("POST", "/cgi-bin/query", params, headers)
response = conn.getresponse()
print response.status, response.reason
200 OK
>>data = response.read()
conn.close()
Jul 7 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.