View Single Post
Unread 26 Aug 2004, 09:55   #5
Structural Integrity
Rawr rawr
 
Structural Integrity's Avatar
 
Join Date: Dec 2000
Location: Upside down
Posts: 5,300
Structural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriend
Re: Parsing other peoples pages and extracting content

Quote:
Originally Posted by JetLinus
Just got a possible PHP solution:


Code:
$f = fopen("http://blahblah","r");
$text = fread($f, 65535);
fclose($f);
65536 is a buffer in this case.
Also look for class_snoopy, a sort of webbrowser control...
yay!!!
It works. Thanks!
I got the page in a variable. I didn't know that fread could read web pages.
BTW, as a sidenote for those who want to use this feature too: if you use fread on a web page it stops reading after it has received a network packet. Use fread in a loop to collect the entire page and not only the first few bytes.
Code:
<?php
$handle = fopen("http://www.example.com/", "rb");
$contents = '';
while (!feof($handle)) {
  $contents .= fread($handle, 8192);
}
fclose($handle);
?>
From:
http://www.php.net/manual/en/function.fread.php
__________________
"Yay"
Structural Integrity is offline   Reply With Quote