I'm developing an app that has to access a list of sites saved in a database, loading all its links. It is a test application but I have encountered a difficulty. The routine is this one:
function crawler() {
include_once './simple_html_dom.php';
//Coloquei este registro em um vetor para dar um exemplo
$sites = array("http://www.folhavitoria.com.br/");
//se eu descomentar a linha abaixo o erro acontece:
// $conecta = mysql_connect("localhost", "root", "");
foreach ($sites as $url){
$html = new simple_html_dom($url);
echo "<br>".$url."</br>";
foreach($html->find("a") as $link){
echo $link->href."<br/>";
}
unset($html);
}
}
Basically what this routine returns to me is a series of links from inside the main page of this site.
It happens that when I put the function mysql_connect
, in order to be able to collect the information of the bank at the time of running the following error message appears:
Fatal error: Call to a member function find () on a non-object in /var/www/html/crawler/simple_html_dom.php on line 1113
updating responding to requests the function that is (next in fact) of line 1113 in simple_html_dom.php is as follows:
function find($selector, $idx=null, $lowercase=false)
{
return $this->root->find($selector, $idx, $lowercase);
}
I have tried several alternatives and I do not know what else to do.
If you want to download Simple_html_dom for testing follow the link: link