urllib help

Brian Kelley bkelley at wi.mit.edu
Wed Aug 1 18:35:40 EDT 2001


I'm struggling with a relatively simply problem.  I'm trying to fill out
the parameters in a form using urllib.  I appear to be able to set the
parameters correctly, but I can't figure out how to submit the form.
That is, I can change the form values to whatever I want but can't
simulate clicking on the go button.

Below the {"term":"wortmannin"} fills in the appropriate section of the
form, i.e. the search term.  How do I actually post the form to the cgi
script?  The following code simply returns the same page as I started
with except that the search entry now says wortmannin instead of being
blank.

Thanks in advance.

import urllib

url =
"http://www.ncbi.nlm.nih.gov:80/entrez/query.fcgi?CMD=search&DB=PubMed"
res = urllib.urlopen(url, urllib.urlencode({"term":"wortmannin"}))

# this just updates the form, it doesn't submit it :(
print res.read()

Brian Kelley
bkelley at wi.mit.edu
Whitehead Institute for Biomedical Research






More information about the Python-list mailing list