[Sussex] For all you PHP / PERL gurus out there...

Gareth Ablett zoomer at zoomer2k.co.uk
Fri Jul 30 21:49:48 UTC 2004


Mark Harrison wrote:

> Here's an interesting one for you.
>  
> Can I call an HTTP page from WITHIN a PHP or PERL script?
>  
> I have a legacy server whose only presented interface is itself a web 
> server. The web server in question is kind of messy, and intended for 
> querying by a particular embedded hardware client rather than by a 
> human driving a browser. Nonetheless, point a browser at it gives a 
> structured response.
>  
> I'm trying to write a human-friendly interface so that the content can 
> be viewed with a web browser in a human-readable format. For various 
> reasons, it makes sense to write this as something that is, itself, a 
> server-side script, rather than a client-side application.
>  
> Hence, can I call an HTTP page from WITHIN a PHP or PERL script (I'm 
> not fussed which.)
>  
> If I can, then I can use either of those languages to parse the 
> content and generate a much prettier web page (including generating 
> links to drill down further, which is the purpose behind all this.)
>  
> I realise that I _could_ shell out to the operating system, run 
> something like Lynx, and then take its STDOUT into STDIN, but this 
> would immediately force a particular piece of client software onto the 
> middleware server, which I don't want for O/S portability reasons.
>  
> Any ideas?
>
> Mark
>  

In php there are a few ways to do this fopen like nik said you can open 
a socket to port 80 and read the content or you could just use include().

the one i would actually use is file() that read the whole file into an 
array whre you can use commands like *strip_tags() to remove any 
formatting and awway you go.*

I dont wish to comment on how to do this with Perl because i dont use it.

Gareth Abltt





More information about the Sussex mailing list