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


Groups > comp.lang.python > #80688

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

Path csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'languages.': 0.04; 'parameters': 0.04; 'django.': 0.05; 'frontend': 0.07; 'apis': 0.09; 'django,': 0.09; 'escape': 0.09; 'http': 0.09; 'orm': 0.09; 'patterns,': 0.09; 'properly.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:script': 0.09; 'things,': 0.09; 'django': 0.11; 'suggest': 0.14; 'concern,': 0.16; 'jumping': 0.16; 'orm,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'sqlalchemy': 0.16; 'subject:PHP': 0.16; 'wrote:': 0.18; 'written': 0.21; 'header:User-Agent:1': 0.23; 'query': 0.26; 'tables': 0.26; 'this:': 0.26; 'pass': 0.26; 'least': 0.26; 'certain': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In- Reply-To:1': 0.27; 'mix': 0.30; 'especially': 0.30; 'larry': 0.31; 'parameters.': 0.31; 'relies': 0.31; 'probably': 0.32; 'languages': 0.32; 'another': 0.32; 'quite': 0.32; '(i.e.': 0.33; 'plain': 0.33; 'core': 0.34; 'subject: (': 0.35; 'subject:with': 0.35; 'skip:u 20': 0.35; 'but': 0.35; 'received:com.au': 0.36; 'doing': 0.36; 'next': 0.36; 'application': 0.37; 'performance': 0.37; 'step': 0.37; 'server': 0.38; 'ajax': 0.38; 'easiest': 0.38; 'to:addr:python-list': 0.38; 'rather': 0.38; 'expensive': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'even': 0.60; 'eventually': 0.60; 'is.': 0.60; 'slowly': 0.60; 'most': 0.60; 'subject:skip:C 10': 0.61; 'new': 0.61; 'making': 0.63; 'more': 0.64; 'great': 0.65; 'charset:windows-1252': 0.65; 'side': 0.67; 'between': 0.67; 'design.': 0.68; 'goal': 0.75; 'actually,': 0.84; 'enforces': 0.84; 'pain': 0.84; 'careful': 0.91; 'received:110': 0.96
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Lie Ryan <lie.1296@gmail.com>
Subject Re: Communicating with a PHP script (and pretending I'm a browser)
Date Fri, 14 Nov 2014 01:54:38 +1100
References <CACwCsY46yYFQwdYdriTSYSvLYF=xs6L2zanN9gofkWkoHvj_fA@mail.gmail.com> <CACwCsY4WYsN4=Vq2WmG895SwToMdfUAJhLqXaQ_02zzaAMzsTw@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host 110-175-240-90.static.tpgi.com.au
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0
In-Reply-To <CACwCsY4WYsN4=Vq2WmG895SwToMdfUAJhLqXaQ_02zzaAMzsTw@mail.gmail.com>
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.15778.1415890500.18130.python-list@python.org> (permalink)
Lines 30
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1415890500 news.xs4all.nl 2950 [2001:888:2000:d::a6]:59936
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:80688

Show key headers only | View raw


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()

I was about that suggest that actually, just be careful to escape things 
properly. Although I would recommend to pass the parameters as request 
body rather than as query parameters. Going through the web server via 
HTTP is most definitely going to be even more expensive than with pipes, 
but if performance is the least of your concern, then this is probably 
the easiest way to include things between languages.

Yet another methods of mixing languages is to use iframes and to built 
your frontend as HTML with that queries Web APIs with AJAX but this 
relies on the client side to do the inclusion.

As your goal is to eventually port an existing site to Python, I would 
highly recommend against using Django. Django, as a full-featured 
framework, is quite opinionated on how to do things, especially in 
regards to database design. While this is great for a new projects as it 
enforces certain well-tested patterns, this can be a pain when you need 
to use existing tables from the PHP application. Also, if your old 
application database access is written in SQL (i.e. with PHP mysql or 
mysqli driver), it might be less friction to port to SQLAlchemy Core 
rather than jumping straight to a full-fledged ORM, eventually you can 
slowly take the next step to port SQLA Core to SQLA ORM. Or you can mix 
and match Core and ORM with SQLAlchemy (with some care); Django is much 
less flexible about mixing plain SQL with ORM.

Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Re: Communicating with a PHP script (and pretending I'm a browser) Lie Ryan <lie.1296@gmail.com> - 2014-11-14 01:54 +1100
  Re: Communicating with a PHP script (and pretending I'm a browser) Roy Smith <roy@panix.com> - 2014-11-13 14:41 -0500

csiph-web