Re: Open and process remote page
- From: Peter Fox <peterfox@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 9 Dec 2005 17:12:24 +0000
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@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 2 Tees Close, Witham, Essex. Gravity beer in Essex <http://www.eminent.demon.co.uk> .
- References:
- Open and process remote page
- From: William Hudson
- Open and process remote page
- Prev by Date: Re: Installation of php and mysql
- Next by Date: Re: Open and process remote page
- Previous by thread: Open and process remote page
- Next by thread: Re: Open and process remote page
- Index(es):
Relevant Pages
|