HELP with HTTPLIB/URLLIB

Cliff Crawford cjc26 at nospam.cornell.edu
Sun Jun 11 20:27:37 EDT 2000


* Alan Alper <al at findacorp.com> menulis:
| I need to duplicate the action of a browser POSTing form data to a server.
| GET is easy, but I don't know how to do POST. Any and all help, preferably
| with examples would be welcome.  Essentially, I'm trying to write a small
| agent to fetch classified ad data from several newspaper websites for me so
| that I don't need to visit the sites manually.  I have no clue how to do a
| POST.

urlopen() takes an optional second argument, which is the data to post.
For example:

urlopen("http://example.org/test.cgi", urlencode({name: "Cliff", id:
"4"})

Also, you might want to take a look at the library reference for urllib:
<http://www.python.org/doc/current/lib/module-urllib.html>


-- 
cliff crawford    -><-    http://www.people.cornell.edu/pages/cjc26/
                          Synaesthesia now!            icq 68165166



More information about the Python-list mailing list