Curl 卷曲域而不卷曲http://www

Curl 卷曲域而不卷曲http://www,curl,subdomain,Curl,Subdomain,嗨,我有一个域,我想用cUrl解析,下面是一个例子: 当我进入域名时 它将我重定向到[register.metsad.ee/avalik/info_teatis.php?too_id=2942704201] 没有http://www也一样。 我用来解析的代码是: function get_data($url) { $ch = curl_init(); $timeout = 5; curl_setopt($ch, CURLOPT_URL, $url)

嗨,我有一个域,我想用cUrl解析,下面是一个例子:

当我进入域名时

它将我重定向到[register.metsad.ee/avalik/info_teatis.php?too_id=2942704201]

没有http://www也一样。 我用来解析的代码是:

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_FOLLOWLOCATION, 1);
        curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
        $data = curl_exec($ch);
        curl_close($ch);
        return $data;
    }
$src = 'http://register.metsad.ee/avalik/info_teatis.php?too_id=2942704201';
然后
$c=get_data($src);
echo$c
对于资源,我得到一个空白的白页。我还尝试使用简单的\u Html\u Dom解析器,如下所示:

echo文件\u get\u html($src)->纯文本

但我还是得到了一张空白的白纸。当我尝试在没有http://的情况下解析时,出现了一个错误

警告:文件获取内容(register.metsad.ee/avalik/info\teatis.php?too\u id=2942704201)[function.file get contents]:打开流失败:第70行C:\xampp\htdocs\Trash\metsakontroll\system\C\u simple\u html\u dom.php中的结果太大

卷曲使屏幕保持白色,没有效果。当我试图像这样解析文件夹时:

然后服务器说找不到


我搜索了整个互联网=/知道如何通过cUrl或Simple_html_dom阅读该页面吗?

register.metsad.ee端有某种保护。在设置
用户代理
标题之前,可以返回空响应

呼叫失败(空响应):

成功调用(返回HTML页面):


试试
http://register.metsad.ee/avalik/info_teatis.php?too_id=2942704201
我看到空白的白色屏幕,因为它没有重定向=(编辑:如果我卷曲标题,那么我会得到这个HTTP/1.1 200 OK日期:Thu,2012年12月13日20:12:27 GMT服务器:Apache内容长度:0内容类型:text/html;charset=UTF-8,这意味着它确实连接到服务器,但由于文件长度为0,它返回给我一个空白页,它不会重定向到没有http://Thanks!!嗯,我添加了那部分
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');
成功了!PS:这是我关于Stackoverflow的第一个问题,我在15分钟内得到了回答,哇,爱你们大家:P!这是一个有趣的案例:)
feedbee@server:~$ telnet register.metsad.ee 80
Trying 213.184.43.115...
Connected to register.metsad.ee.
Escape character is '^]'.
GET /avalik/info_teatis.php?too_id=2942704201 HTTP/1.1
Host: register.metsad.ee

HTTP/1.1 200 OK
Date: Thu, 13 Dec 2012 20:07:11 GMT
Server: Apache
Content-Length: 0
Content-Type: text/html; charset=UTF-8
feedbee@server:~$ telnet register.metsad.ee 80
GET http://register.metsad.ee/avalik/info_teatis.php?too_id=2942704201 HTTP/1.1
Host: register.metsad.ee
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0

HTTP/1.1 200 OK
Date: Thu, 13 Dec 2012 20:13:07 GMT
Server: Apache
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: SNS=a0e425c2aec17c38be3716b366f75749; path=/
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8

762
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
...
curl_setopt($ch, So you need to add CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0"); for example (or any other user agent string).