Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/244.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 文件\u获取\u内容或cURL不提供任何输出_Php - Fatal编程技术网

Php 文件\u获取\u内容或cURL不提供任何输出

Php 文件\u获取\u内容或cURL不提供任何输出,php,Php,我正在尝试获取url的内容: 我尝试了file\u get\u 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_setop

我正在尝试获取url的内容:

我尝试了file\u get\u 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;

此站点不允许脚本调用。在其响应标题中,它指出:

$ curl -I https://allegro.pl
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
…
X-Content-Type-Options: nosniff

nosniff
在此解释:

此站点不允许脚本调用。在其响应标题中,它指出:

$ curl -I https://allegro.pl
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
…
X-Content-Type-Options: nosniff

nosniff
在这里进行了解释:

我没有点击这个随机URL-它是真实的URL吗?它是从浏览器加载的吗?是的,它是真实的URL,从浏览器加载。这是一个类似于易趣的巨大网站。可能是因为他们不想让你把它删除。我测试了你的代码并成功了。哦!我看到它在phpfiddle.org上运行-但是我不能在我的服务器上运行它的原因是什么…我没有点击这个随机的URL-它是真实的URL吗?它是从浏览器加载的吗?是的,它是真实的URL,从浏览器加载。这是一个类似于易趣的巨大网站。可能是因为他们不想让你把它删除。我测试了你的代码并成功了。哦!我看到它在phpfiddle.org上运行-但我不能在我的服务器上运行它的原因是什么。。。