This is my code:
<?php
require('phpQuery.php');
function download($url)
{
$curl = curl_init();
curl_setopt_array($curl, array
(
CURLOPT_URL => $url,
CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/22.0.1207.1 Safari/537.1',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CONNECTTIMEOUT => 120,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HEADER => false
));
$data = curl_exec($curl);
curl_close($curl);
return $data;
}
$pagina1 = phpQuery::newDocument(download('http://google.com'));
$logosrc = pq('img#hplogo').attr('src');
echo $logosrc;
?>
Error:
Fatal error: Call to undefined function attr() in C:\xampp\htdocs\projects\new\extract.php on line 26
Who know where is the problem?
Change
$logosrc = pq('img#hplogo').attr('src');
To be
$logosrc = pq('img#hplogo')->attr('src');
I think, but I haven't tested it.