0
以下是我的代码,我试图抓取以下URL,但由于某些原因,html源代码根本没有被刮掉。为什么在这个URL上不会发生刮擦?无法刮取Zazzle产品网址
我试图使用File_get_contents
以及简单的HTML DOM库,但它没有刮。
URL: http://www.zazzle.com/protoceratops_t_shirt-235065458404753105
function get_data($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
echo get_data('http://www.zazzle.com/protoceratops_t_shirt-235065458404753105');
您是否收到错误?该代码是否仅为'http:// www.google.com /'返回任何内容? – castis