[Python-talk] Generating form data multipart MIME for httplib, urllib{, 2} Request objects

Lloyd Kvam lkvam at venix.com
Thu Apr 27 14:21:28 EDT 2006


On Thu, 2006-04-27 at 13:37 -0400, Bill Freeman wrote:
> I'm attempting to use python to submit --- NOT SERVICE --- forms data
> using POST.
> 
So you are talking HTTP here using the POST method.  The function you
want is urlencode in the urllib module.  Pass it a list of key-value
pairs or a dictionary.  It builds what's needed.  Pass it as postdata to
the urllib (or urllib2) open function along with the URL you want to
POST to.  The presence of the postdata changes the method from GET to
POST.

If there are cookies and stuff involved it can get a little more
complicated.  I can send you some sample code if needed.  

(I collect baseball stats and the code has to login and handle cookies,
so it is not a great first example.)



-- 
Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358

voice:  603-653-8139
fax:    320-210-3409



More information about the Python-talk mailing list