其它网站可以获取到,为什么这个不可以。curl也不行,求解答,谢谢。
其它网站可以获取到,为什么这个不可以。curl也不行,求解答,谢谢。
|
1
这是DNSPod的IP~
|
|
2
换了学校的VPS以及自己的虚拟机,都有问题~可以获取到httpheader,就是无法获取内容。
|
|
l12abMar 29, 2015
3
123.125.114.144;180.149.132.47
|
|
PuteulanusMar 29, 2015
4
file_get_contents curl 楼主看看是不是网的问题? |
|
5
@Puteulanus 应该不是网络问题啊,get_headers('http://119.29.29.29/d?dn=baidu.com')可以获取到httpheader,就是file_get_contents不行。
|
|
NewYearMar 29, 2015
6
我用file_get_contents获取某大人站的首页做RSS,结果一段时间后被对方服务器B掉了IP……ping都ping不通了。
后来自己请求了下自己网站才发现,坑爹的,这玩意发请求不带user-agent,难怪人家要屏蔽,是我我也屏蔽 |
|
txltyMar 29, 2015
7
<?php
$fp = fsockopen("119.29.29.29", 80); fwrite($fp,"GET /d?dn=baidu.com HTTP/1.1\r\n"); fwrite($fp,"Host: 119.29.29.29\r\n"); fwrite($fp,"Connection: Close\r\n\r\n"); for($i=0;$i<6;$i++){$data.=fgets($fp, 128);} preg_match("/Content-Length:.?(\d+)/", $data, $matches); $length = $matches[1]; $result = fgets($fp, $length+1); fclose($fp); echo $result; ?> |
|
xbonlineMar 29, 2015
8
这是file_get_contents的坑
因为服务器开启了keep-alive file_get_contents默认是不发送connection:close头,服务器以为还有后续http请求,所以继续等待几十秒才close,导致file_get_contents阻塞 解决方案: http://stackoverflow.com/questions/3629504/php-file-get-contents-very-slow-when-using-full-url |
|
bomblessMar 29, 2015
10
那就是错误的默认参数吧……
|
|
mingyunApr 5, 2015
12
擦,我试了也不行
|
|
14
更正,curl可以~
|