php curl刮不工作

时间:2015-10-08 12:16:50

标签: php curl

我的抓取代码无效,我使用了php cURL,但没有返回页面内容。所以请帮助我,我怎样才能获得所有内容。

function getSslPage($url)
{
    $ch = curl_init();

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_REFERER, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);

    $result = curl_exec($ch);
    curl_close($ch);

    return $result;
}

$url = "https://www.woolworths.com.au/Shop/SearchProducts?search=Fresh%20Apple";
$ch = getSslPage($url);

echo $ch;

1 个答案:

答案 0 :(得分:0)

curl_exec()来电后立即添加此内容,并在此处复制/粘贴输出:

if (curl_errno($ch)) {
  throw new Exception(curl_error($ch));
}