卷曲 return 'Empty reply from server'
Curl return 'Empty reply from server'
我需要从我的服务器中提取一个 HTTPS 页面并使用 cURL 打印错误 'Empty reply from server'。
这是我的代码:
<?php
$ch = curl_init();
$headers = array('HTTP_ACCEPT: Something', 'HTTP_ACCEPT_LANGUAGE: fr, en, da, nl, it', 'HTTP_CONNECTION: Something');
curl_setopt($ch, CURLOPT_URL, 'https://gibbohotel.it/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec( $ch );
if(curl_exec($ch) === false)
{
echo 'Curl error: ' . curl_error($ch);
}
else
{
echo 'Operation completed without any errors';
}
curl_close($ch);
?>
是否是外部服务器的代理问题?
此特定站点拒绝 curl 查询 - 命令行查询 returns 同样的结果。所以你必须假装你正在使用 CURLOPT_USERAGENT.
的其他用户代理
<?php
$ch = curl_init();
$headers = array('HTTP_ACCEPT: Something', 'HTTP_ACCEPT_LANGUAGE: fr, en, da, nl, it', 'HTTP_CONNECTION: Something');
curl_setopt($ch, CURLOPT_URL, 'https://gibbohotel.it/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
$result = curl_exec( $ch );
if(curl_exec($ch) === false)
{
echo 'Curl error: ' . curl_error($ch);
}
else
{
echo 'Operation completed without any errors';
}
curl_close($ch);
?>
但是,该站点可能有一些原因无法通过 curl 或类似方式收获,所以不要抱怨,如果这样做会被阻止...
我需要从我的服务器中提取一个 HTTPS 页面并使用 cURL 打印错误 'Empty reply from server'。 这是我的代码:
<?php
$ch = curl_init();
$headers = array('HTTP_ACCEPT: Something', 'HTTP_ACCEPT_LANGUAGE: fr, en, da, nl, it', 'HTTP_CONNECTION: Something');
curl_setopt($ch, CURLOPT_URL, 'https://gibbohotel.it/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec( $ch );
if(curl_exec($ch) === false)
{
echo 'Curl error: ' . curl_error($ch);
}
else
{
echo 'Operation completed without any errors';
}
curl_close($ch);
?>
是否是外部服务器的代理问题?
此特定站点拒绝 curl 查询 - 命令行查询 returns 同样的结果。所以你必须假装你正在使用 CURLOPT_USERAGENT.
的其他用户代理<?php
$ch = curl_init();
$headers = array('HTTP_ACCEPT: Something', 'HTTP_ACCEPT_LANGUAGE: fr, en, da, nl, it', 'HTTP_CONNECTION: Something');
curl_setopt($ch, CURLOPT_URL, 'https://gibbohotel.it/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
$result = curl_exec( $ch );
if(curl_exec($ch) === false)
{
echo 'Curl error: ' . curl_error($ch);
}
else
{
echo 'Operation completed without any errors';
}
curl_close($ch);
?>
但是,该站点可能有一些原因无法通过 curl 或类似方式收获,所以不要抱怨,如果这样做会被阻止...