Click to See Complete Forum and Search --> : PHP - Reading a Webpage


SolarFlare
January 24th, 2005, 08:27 AM
So I'd like to be able to read the source of a foreign page http://whatever into a variable so that I can parse it and do funky things to it. How is that done?

khp
January 24th, 2005, 11:10 AM
Use the file function
http://dk.php.net/manual/en/function.file.php

SolarFlare
January 24th, 2005, 03:09 PM
Thanks khp.

poolwin2001
March 9th, 2005, 03:33 AM
alternate and more lenghty way:

br = new COM("InternetExplorer.Application");
$br->visible=1;
$br->navigate('http://yoursite.com');
echo $br->Document->body->innerHTML;

bigBA
March 10th, 2005, 09:12 AM
alternate and more lenghty way:

br = new COM("InternetExplorer.Application");
$br->visible=1;
$br->navigate('http://yoursite.com');
echo $br->Document->body->innerHTML;


so... now try to execute this script with a linux installation of webserver/apache :wave:

Sander@the-new-world.com
April 18th, 2005, 03:28 PM
I use the following function to get the code of a document into a variable and edit it before displaying it.

file_get_contents

Kind regards,

Sander
http://www.the-new-world.com
The #1 Webdevelopment and Webhosting Portal