Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!bloom-beacon.mit.edu!bloom-beacon.mit.edu!panix!roy From: Roy Smith Newsgroups: comp.lang.python Subject: Re: Communicating with a PHP script (and pretending I'm a browser) Date: Thu, 13 Nov 2014 14:41:46 -0500 Organization: PANIX Public Access Internet and UNIX, NYC Lines: 14 Message-ID: References: NNTP-Posting-Host: localhost X-Trace: reader1.panix.com 1415907706 17456 127.0.0.1 (13 Nov 2014 19:41:46 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Thu, 13 Nov 2014 19:41:46 +0000 (UTC) User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) Xref: csiph.com comp.lang.python:80699 In article , Lie Ryan wrote: > On 13/11/14 03:57, Larry Martell wrote: > > We were all making this much harder than it is. I ended up doing this: > > > > wp = urllib.request.urlopen('http://php_page/?' + request.POST.urlencode()) > > pw = wp.read() You can do this if you want, but it's much easier to use requests library (http://docs.python-requests.org/). Compared to using the raw urllib stuff, requests makes it trivial to deal with argument encoding, cookie management, and a zillion other little details which will drive you crazy if you try to roll your own with urllib.