...

View Full Version : Screen Scrape



stfc_boy
11-07-2007, 04:43 PM
Hi All,

I'm trying to screen scrape a table on my site to another of my sites. However I just get a blank page:



<?
$htmlSrc='http://www.sloughtownfc.net/league_table/index.php';
function captureFragment($str,$start_delim,$end_delim) {
$start = strpos($str,$start_delim) + strlen($start_delim);
$end = strpos($str,$end_delim,$start);
return substr($str,$start,$end - $start);
}

$table = captureFragment($htmlSrc,'<table width="100%" class="player_stats2">','</table>');

?>


Any ideas?

Thanks

Chris

mlse
11-07-2007, 04:49 PM
You need to curl (http://uk2.php.net/manual/en/ref.curl.php) the webpage into a local variable using output buffering (http://uk2.php.net/manual/en/function.ob-start.php) and then apply your captureFragment function. Or you can use file_get_contents (http://uk2.php.net/manual/en/function.file-get-contents.php) (a lot easier), depending on your PHP setup.

Please post again if you don't understand why!

Regards,

Mike.

stfc_boy
11-07-2007, 04:57 PM
Thanks. I'll take a look...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum