Communicating with a PHP script (and pretending I'm a browser)
Roy Smith
roy at panix.com
Thu Nov 13 14:41:46 EST 2014
In article <mailman.15778.1415890500.18130.python-list at python.org>,
Lie Ryan <lie.1296 at gmail.com> 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.
More information about the Python-list
mailing list