Code Comments
Programming Forum and web based access to our favorite programming groups.Very basic: What is the easiest way in php to download the source code (HTML etc.) of a given URL (say, http://www.google.com) and parse this code for certain patterns? I guess my question can be split in two: 1) How do I download a webpage (into a string or whatever)? 2) How can I do string manupulation, regexp matching, information extraction etc. on the downloaded information? /David
Post Follow-up to this messageDavid Rasmussen wrote: > Very basic: > > What is the easiest way in php to download the source code (HTML etc.) > of a given URL (say, http://www.google.com) and parse this code for > certain patterns? > > I guess my question can be split in two: > > 1) How do I download a webpage (into a string or whatever)? > > 2) How can I do string manupulation, regexp matching, information > extraction etc. on the downloaded information? > > /David Download: $file = fopen("http://www.google.com","r"); while (!eof($file)) { $buffer = fgets($file, 512); } and then you just do whatever you want with $buffer. Afaik. S
Post Follow-up to this messageOn Fri, 22 Apr 2005 03:27:55 +0300, Sander Van de Moortel <sander@jnm.be>
wrote:
> David Rasmussen wrote:
> Download:
>
> $file = fopen("http://www.google.com","r");
> while (!eof($file)) {
> $buffer = fgets($file, 512);
> }
>
> and then you just do whatever you want with $buffer.
>
> Afaik.
>
> S
that !eof is invalid as a check. it should be
while (!feof($file))
--
"Two things are infinite: the universe and human stupidity; and I'm not
sure about the first one." - Albert Einstein
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.