python and http POST

galileo228 mattbarkan at gmail.com
Thu Feb 11 14:11:51 EST 2010


Hey All,

Been teaching myself Python for a few weeks, and am trying to write a
program that will go to a url, enter a string in one of the search
fields, submit the search, and return the contents of the search
result.

I'm using httplib2.

My two particular questions:

1) When I set my 'body' var, (i.e. 'body = {'query':'search_term'}),
how do I know what the particular key should be? In other words, how
do I tell python which form on the web page I'm visiting I'd like to
fill in? Do I simply go to the webpage itself and look at the html
source? But if that's the case, which tag tells me the name of the
key?

2) Even once python fills in the form properly, how can I tell it to
'submit' the search?

Thanks all!

Matt



More information about the Python-list mailing list