0

这是我的代码:

    <?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;


?>

错误:

致命错误:在第 26 行调用 C:\xampp\htdocs\projects\new\extract.php 中未定义的函数 attr()

谁知道问题出在哪里?

4

1 回答 1

1

改变

$logosrc = pq('img#hplogo').attr('src');

成为

$logosrc = pq('img#hplogo')->attr('src');

我想,但我没有测试过。

在这里查看更多信息

于 2012-11-10T14:32:13.920 回答