I'm trying to scrape data from several links which i retrieve from a xml file. However i keep getting an error which only seem to appear on some of the news. below you can see the output i get
http://www.hltv.org/news/14971-rgn-pro-series-groups-drawnRGN Pro Series groups drawn
http://www.hltv.org/news/14969-k1ck-reveal-new-teamk1ck reveal new team
http://www.hltv.org/news/14968-world-championships-captains-unveiled
Fatal error: Call to a member function find() on a non-object in /app/scrape.php on line 266
where this is line 266
$hltv_full_text = $hltv_deep_link->find("//div[@class='rNewsContent']", 0);
Full code
Scrape function
function scrape_hltv() {
$hltv = "http://www.hltv.org/news.rss.php";
$sxml = simplexml_load_file($hltv);
global $con;
foreach($sxml->channel->item as $item)
{
$hltv_title = (string)$item->title;
$hltv_link = (string)$item->link;
$hltv_date = date('Y-m-d H:i:s', strtotime((string)$item->pubDate));
echo $hltv_link;
//if (date('Y-m-d', strtotime((string)$item->pubDate)) == date('Y-m-d')){
if (strpos($hltv_title,'Video:') === false) {
$hltv_deep_link = file_get_html($hltv_link);
$hltv_full_text = $hltv_deep_link->find("//div[@class='rNewsContent']", 0);
echo $hltv_title . '<br><br>';
}
//}
}
}
scrape_hltv();