Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Downloading and parsing web-stuff
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

Report this thread to moderator Post Follow-up to this message
Old Post
David Rasmussen
04-22-05 08:55 AM


Re: Downloading and parsing web-stuff
David 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

Report this thread to moderator Post Follow-up to this message
Old Post
Sander Van de Moortel
04-22-05 08:55 AM


Re: Downloading and parsing web-stuff
On 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

Report this thread to moderator Post Follow-up to this message
Old Post
Bender Rodriguez
04-24-05 08:55 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP Language archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:25 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.