We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

web Scraping Phalcon

Hi, I've a problem on web scraping in Phalcon (I have made a reference to it in condigo Zend 2 working properly, but do not realize Phalcon). Code:

public function getDataFromWS(){ $site = "https://peru.todoautos.com.pe/catalogo-nuevos/autos/-/kia/-";

    $content = file_get_contents($site);
    $html = mb_convert_encoding($content, 'UTF-8', mb_detect_encoding($content, 'UTF-8, ISO-8859-1', true));
    $dom = new Query($html);

    $result=$dom->execute('.new-vehicle-info');

    $data="";
    foreach ($result as $element){
        $value=preg_replace('/\s+/', ' ', $element->nodeValue);
        $data=$data.$value."\n";
    }

    return $data;
}

which method gives you Phalcon for web scraping and data extraction from a web?


85.5k

i have my doubts phalcon has dom scraping tool, but everytime i used php for scraping i always had problems, for this reason i use casper js.