Getting Php Curl Error -


i want grab first 10 results of url passed function parameter ..and want make data scraper sites

getting syntax error when print result on screen syntax error on line don't why giving me syntax error kindly me....

print_r( $dse->crawl()->parse() );

<?php                      class curl_crawler{       public $url;       public $request_type;       public $data;       public $post_params;    function __construct($url = '' , $request_type = 'get')   {      $this->url = $url;      $this->request_type = $request_type;      $this->data = '';      $this->post_params = array();    } /**crawl document **/  function crawl()    {     $curl = curl_init( $this->url );     curl_setopt($curl, curlopt_header, false);     curl_setopt($curl, curlopt_timeout, 60);     curl_setopt($curl, curlopt_useragent, 'curl php');     curl_setopt($curl, curlopt_returntransfer, true);     $this->data = curl_exec($curl);     curl_close($curl);     return $this; //make chainable method    } /** parse result data **/    function parse(){    $result = array();    $count = 0;    $dom = new domdocument;    $dom->preservewhitespace = false;    $dom->loadhtml($this->data);    $xpath = new domxpath($dom);    $news = $xpath->query('//td[@bgcolor="#dddddd"]/table/tr[position()=2]/td[position()=2]');    foreach( $news $n){        $result[] =   $n->nodevalue;        $count++;        if ($count >9)            break; //we need  10 results. index starts 0    }    return $result;       }     }  error_reporting(0);         $dse = new curl_crawler('http://www.dsebd.org/display_news.php');     echo "<pre>";     print_r( $dse-&gt;crawl()-&gt;parse() );     echo "<pre>";     ?> 

your syntax error should use explicit "greater than" sign instead of html entities &gt; - server doesn't need those, not browser can render correctly. change:

print_r( $dse-&gt;crawl()-&gt;parse() );               ^^^^        ^^^^ 

to:

print_r( $dse->crawl()->parse() ); 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -