...

View Full Version : Can PHP read an HTML page?



erdubya
04-03-2007, 08:40 PM
It may sound kind of crazy, but I'm trying to see if there's a way php code can 'read' contents of a static HTML page and store the contents into a variable.

Is it possible? If so, how?

For example,

1. PHP reads http://anysite.com/anypage.html

2. PHP stores all contents of that page into a variable.

Thanks for your help!

Elliott
http://projectvibe.net

nikkiH
04-03-2007, 08:41 PM
I think they call it curl.
http://us3.php.net/curl

Nightfire
04-03-2007, 08:41 PM
http://uk2.php.net/file_get_contents

erdubya
04-03-2007, 09:00 PM
Thanks for the reply... and it works... sort of.

See the URL where i'm trying to get contents from is actually a windows media publishing point.. so there is no visible 'file' in the url.

The url is http://212.72.165.21:8000/projectvibe/

is there a way to get contents of this url?

Thanks,

Elliott
http://projectvibe.net

rafiki
04-03-2007, 09:10 PM
<?php
get_file_contents("http://212.72.165.21:8000/projectvibe/");
?>

jlhaslip
04-03-2007, 09:34 PM
Good tunes, thanks.

erdubya
04-03-2007, 09:38 PM
<?php
get_file_contents("http://212.72.165.21:8000/projectvibe/");
?>


I already tried that (including the url) and unfortunately it doesn't work. It waits for a few seconds and produces a blank page.

CFMaBiSmAd
04-03-2007, 09:52 PM
It does work for me -

<?php
$content = file_get_contents("http://212.72.165.21:8000/projectvibe/");
echo $content;
?>Either url_fopen is not enabled on your server or the site is not reachable from where you are attempting to do this.

Either check your web server log for errors and/or put the following two lines in after your first opening <?php tag -

ini_set ("display_errors", "1");
error_reporting(E_ALL);



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum