Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #80612

Re: Communicating with a PHP script (and pretending I'm a browser)

Path csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-1.proxad.net!hq-usenetpeers.eweka.nl!hq-usenetpeers.eweka.nl!bcyclone03.am1.xlned.com!bcyclone03.am1.xlned.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <larry.martell@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'python.': 0.02; 'django.': 0.05; 'output': 0.05; 'string': 0.09; 'back.': 0.09; 'subject:script': 0.09; 'python': 0.11; 'code?': 0.16; 'expects': 0.16; 'subject:PHP': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'app': 0.19; 'later': 0.20; 'code,': 0.22; 'input': 0.22; 'to:name :python-list@python.org': 0.22; "i've": 0.25; 'script': 0.25; 'first,': 0.26; 'this:': 0.26; 'post': 0.26; 'header:In-Reply- To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'larry': 0.31; 'view.': 0.31; 'subject: (': 0.35; 'subject:with': 0.35; 'skip:u 20': 0.35; 'convert': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'html,': 0.36; 'templates': 0.36; 'doing': 0.36; 'nov': 0.38; 'to:addr:python- list': 0.38; 'issue': 0.38; 'to:addr:python.org': 0.39; 'is.': 0.60; 'subject:skip:C 10': 0.61; 'making': 0.63; 'heavy': 0.81; 'curl': 0.84; 'lifting': 0.84; 'route': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=WKs/yyZjqZlGfNTfl4j66ayYwiROSwHB0ZepeFAJ2Y4=; b=JzkgTPuXnFpejzkM0gTU96B/iG1mLnrPB8TykCNnXjNezsLHQYXSMstU6nUALQfAtR f9dyV6vrZFdQfjKMcwInQUrDLi8X7PKk1/H9TvFajJf89NhHqpdhHUSKCkbHWrWuE0Sg LmAXoaVUoq4UUfLFY6Reeb7FkUeJ+wIsLhYSsQBatF9otdtGCL2wg6cv6R+7f1SncxH7 gZTbW1xXIhO+KK0QRl8cvNoxS0gWwo9eP3qyZGRX+JhTGEPRbhbuv4opcDjubm/oUuAT jXZqdt62ytU+wTzlKQekx5X8cO+7skwc67EG8vQ+32NT1wU6/KmrVBKxOUJ3KNRSx5cQ xxJg==
MIME-Version 1.0
X-Received by 10.194.236.232 with SMTP id ux8mr66052017wjc.96.1415811430675; Wed, 12 Nov 2014 08:57:10 -0800 (PST)
In-Reply-To <CACwCsY46yYFQwdYdriTSYSvLYF=xs6L2zanN9gofkWkoHvj_fA@mail.gmail.com>
References <CACwCsY46yYFQwdYdriTSYSvLYF=xs6L2zanN9gofkWkoHvj_fA@mail.gmail.com>
Date Wed, 12 Nov 2014 11:57:10 -0500
Subject Re: Communicating with a PHP script (and pretending I'm a browser)
From Larry Martell <larry.martell@gmail.com>
To "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.15728.1415811433.18130.python-list@python.org> (permalink)
Lines 18
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1415811433 news.xs4all.nl 2900 [2001:888:2000:d::a6]:35982
X-Complaints-To abuse@xs4all.nl
X-Received-Body-CRC 2175689053
X-Received-Bytes 4246
Xref csiph.com comp.lang.python:80612

Show key headers only | View raw


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


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