用于加密页面的PHP Curl


PHP Curl for encrypted pages

我对这个网站进行了php卷曲http://www.hoovers.com/company-information/company-search.html

但它返回404。看起来像是加密的东西。

你能给我一些关于这个问题的线索吗。感谢

        // Get cURL resource
    $curl = curl_init();
    // Set some options - we are passing in a useragent too here
    curl_setopt_array($curl, array(
        CURLOPT_RETURNTRANSFER => 1,
        CURLOPT_URL => 'http://www.hoovers.com/company-information/company-search.html',
    ));
    // Send the request & save response to $resp
    $resp = curl_exec($curl);
    // Close request to clear up some resources
    curl_close($curl);

看起来他们的web服务器拒绝了基于HTTP标头的请求。或者它也可能在应用程序级别。试试这个

<?php
// Get cURL resource
$curl = curl_init();
// Set some options - we are passing in a useragent too here
curl_setopt_array($curl, array(
    CURLOPT_RETURNTRANSFER => 1,
    CURLOPT_HEADER=>1,
    CURLOPT_URL => 'http://www.hoovers.com/company-information/company-search.html',
    CURLOPT_HTTPHEADER=> array(
        'User-Agent: Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0', 'Accept-Language: en-US,en;q=0.5'
        )
    ));
// Send the request & save response to $resp
$resp = curl_exec($curl);
// Close request to clear up some resources
curl_close($curl);
//debug
print_r($resp);
?>