我对这个网站做了一个php curl 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);
答案 0 :(得分:0)
看起来他们的网络服务器拒绝基于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);
?>