Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #80612
| References | <CACwCsY46yYFQwdYdriTSYSvLYF=xs6L2zanN9gofkWkoHvj_fA@mail.gmail.com> |
|---|---|
| Date | 2014-11-12 11:57 -0500 |
| Subject | Re: Communicating with a PHP script (and pretending I'm a browser) |
| From | Larry Martell <larry.martell@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.15728.1415811433.18130.python-list@python.org> (permalink) |
On Tue, Nov 11, 2014 at 10:48 AM, Larry Martell <larry.martell@gmail.com> wrote:
> I have a PHP app that I want to convert to django. But I want to do it
> stages. All the heavy lifting is in the PHP code, so first, I want to
> just use templates and views to generate the HTML, but still call the
> PHP code. Then later convert the PHP to python.
>
> My issue is that the PHP code expects to get all it's input from the
> REQUEST object and I've consumed that in the view. Is there any way I
> can somehow supply that to the PHP code?
>
> Is there some way python can communicate like curl ... it needs to
> send the request string in the body of a POST request to the URL that
> will route to the PHP script and get the output back.
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()
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Communicating with a PHP script (and pretending I'm a browser) Larry Martell <larry.martell@gmail.com> - 2014-11-12 11:57 -0500
csiph-web