I’m using Apache 2.0.55 with PHP 4.4.2 on Win XP SP2. I was concerned to learn something about scrape technologies and after searching on Google I found a few tutorials and suggestion how to do it. But … :{
I made some virtual folder on localhost on my computer, prepare a php page and start to write script.
I wrote script like this one:
<?php
$url = "http://www.nfl.com/teams/sandiegochargers/roster?team=SD";
$raw = file_get_contents($url);
$newlines = array(" ","
","\r","\x20\x20","\0","\x0B");
$content = str_replace($newlines, "", html_entity_decode($raw));
$start = strpos($content,'<table cellpadding="2" class="standard_table"');
$end = strpos($content,'</table>',$start) + 8;
$table = substr($content,$start,$end-$start);
preg_match_all("|<tr(.*)</tr>|U",$table,$rows);
foreach ($rows[0] as $row){
if ((strpos($row,'<th')===false)){
preg_match_all("|<td(.*)</td>|U",$row,$cells);
$number = strip_tags($cells[0][0]);
$name = strip_tags($cells[0][1]);
$position = strip_tags($cells[0][2]);
echo "{$position} - {$name} - Number {$number} <br>
";
}
}
?>
I saved it like scrapeit.php and execute in IE and later in FF, but got twice Fatal error about Apache and nothing happend in window of IE (FF) :{
Why? I tried some other (and smaller) scripts but same thing when I used function file_get_contents()! :d: Do you know guys why!?