[SOLVED] Capturing the text of a web page and putting it in

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Paddy
Forum Contributor
Posts: 244
Joined: Wed Jun 11, 2003 8:16 pm
Location: Hobart, Tas, Aussie
Contact:

Capturing the text of a web page and putting it in a string

Post by Paddy »

Ok, I am not even sure if this can be done but I would be happy if it could.

I need a function so I can grab the text of a given URL so that I can manipulate it. Ideally I would like it to be placed in a string. So...

$somestring = somefunc("http://www.someurl.com");

Any ideas?
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Code: Select all

$somestring = file_get_contents('http://www.someurl.com');
(also see http://php.net/file if you want each line of the remote site as an element of an array)
Paddy
Forum Contributor
Posts: 244
Joined: Wed Jun 11, 2003 8:16 pm
Location: Hobart, Tas, Aussie
Contact:

Post by Paddy »

Which is pretty much why I absolutely love this site. :)

Thanks heaps Mark. :)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

if you don't have URL wrappers on, for whatever reason. You will need something like [php_man]curl[/php_man]
Post Reply