You are here: Re: Open and process remote page « PHP Programming Language « IT news, forums, messages
Re: Open and process remote page

Posted by Peter Fox on 12/09/05 19:12

Following on from William Hudson's message. . .
>I want to be able to ask users for a URL, open that page, change some of the
>contents and then display that page as if they had typed the URL into a
>browser. I have toyed with some of the php functions for opening URLs, but
>what I am not clear on is how much work my script will have to do (do I need
>to fully emulate a browser, for example).
>
>The net effect I am after is very similar to the page translation feature
>that Google offers. Does anyone have any examples of this kind of technique.
>Any ideas how much work is involved? (My 'translation' is pretty trivial, so
>really it is mostly a question of how much work to display the remote page).

Personally I'd approach this by writing a proxy server in Java and deal
at the header level with http requests/responses rather than try to be
an arms-length browser/server.

With your PHP approach: If you want to 'serve' mydomain.com/index.htm
then you need to fetch it, parse it recursively looking for urls inside
frameset, css and javascript and perhaps hack them and at least fetch
them. A 'web page' is not necessarily a single entity. Suppose
index.htm is just a frameset. You could 'translate' this as much as you
like but the 'real' content would be missed.

With the proxy server you look for http responses with mime types of
interest and translate the data as appropriate then pass on.

Java Examples In A Nutshell (Pub. O'Reilly) shows how straightforward it
is. You'd need to bootstrap a proxy session from your normal PHP pages
by telling it who's calling and what they want to see.

--
PETER FOX Not the same since the borehole business dried up
peterfox@eminent.demon.co.uk.not.this.bit.no.html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.demon.co.uk>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация