Jump to content

Help with screen scraping(Code Already Started)


coreysnyder04

Recommended Posts

My Goal: To Scrape the screen for the stats table on this page: http://www.thechiller.com/page9571.cfm. Its right in the middle with a dark blue background.

 

I was using this code:

<?php
$tempDoc = new DOMDocument();
$tempDoc->loadHTMLFile("http://www.thechiller.com/page757.cfm");
$elements = $tempDoc->getElementsByTagName('td');


if (!is_null($elements)){
    foreach($elements as $element){
        $tempString = $element->nodeValue;
        $tempString = strip_tags($tempString);
        if(strstr($tempString,'GA')&& strlen($tempString)<6){
            $InsideStats = true;
        }
        if($tempString == ""){
            $InsideStats = false;
        }
        if($InsideStats==true){
            echo "'".$tempString."'<br/>";     
        }
         
    }
}

 

And I almost had it. But then I switched to another league page on the site "C-West" with a similar table and BAM, everything went to crap and it just returns:

' GA'

' Wednesday, November 4, 2009'

 

I took away all the logic so its doing the "echo "'".$tempString."'<br/>";      " every $element and it ends @ the same place. It doesn't make sense and its pissing me off. Any ideas? If anyone could whip up some PHP that would scrape this table off any of the league pages that would be phenomenal!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.