I’m using requests (as adviced by Daniel Roseman) to post on a webform:
url = "http://mascot.proteomics.dundee.ac.uk/cgi/search_form.pl?FORMVER=2&SEARCH=MIS"
data = {'SEARCH':'MIS'}
files = {'JG-C1-1A.mgf' : open('/homes/ndeklein/Cantrell/JG-C1-1.mgf','rb')} print
when I print r.ok and r.request I get 200 ok, so the POST worked. When I print the r.content I don’t get the result page but html of the page where the form is submitted. When I remove the {'SEARCH':'MIS'} from data r.content returns a html error page that the search type is missing, so I know that if something is wrong in the post I get an error.
So how can I get the result page?
There’s no reason to use
httplib, honestly. It’s a low-level interface and is unnecessarily complex for what you want to do. At the very least, useurllib2, which will follow any redirects. But probably your best bet is to use the third-partyrequestsmodule which makes all this a ton easier.