我正在尝试获取url的内容:https://allegro.pl
我已经尝试了file_get_contents和cURL,但该特定域的输出为空。与任何其他网站都可以正常工作...
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://allegro.pl/");
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)');
$output = curl_exec($ch);
curl_close($ch);
echo $output;
答案 0 :(得分:2)
该站点不允许被脚本调用。在响应标头中指出:
$ curl -I https://allegro.pl
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
…
X-Content-Type-Options: nosniff
nosniff
的说明如下:https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-Options#Syntax