HTTP/1.1 500 ( Host was not found. For more information about this event, see ISA Server Help. ) Via:1.1 ISA Connection: close Proxy-Connection: close Pragma: no-cache Cache-Control: no-cache Content-Type: text/html Content-Length: 1987 =============显示错误========
function read_url($url='http://www.xxxx.com/index.php'){
$hwand = fopen($url,'r');
$get_content = '';
while (!feof($hwand)){
$get_content .= fgets($hwand,4096);
}
fclose($hwand);
if ($get_content!=''){
printf("取得内容如下:<hr>\r\n%s",$get_content);
}
}
可能fopen函数,省略了某些标识吧,你可以拿socket函数,提交完整的http头就行了
$url = "http://www.abc.com/abc.asp"; $Parten = "/^http:\/\/(.*?)\/(.*)$/i";
preg_match($Parten,$Url,$Matches); $ServerName = $Matches[1];
$FilePath = "/".$Matches[2]; if(empty($ServerName) || empty($FilePath)) return false; $Parten = "/^(.*?):(\d+)$/i";
preg_match($Parten,$ServerName,$Matches); $ServerName = $Matches[1]; $ServerPort = empty($Matches[2])?"80":$Matches[2]; //与服务器通信
$socket = socket_create(AF_INET, SOCK_STREAM, 0);
if($socket < 0)
{
return false;
} $result = socket_connect($socket, $ServerName, $ServerPort);
if ($result < 0)
{
return false;
} $in = "GET ".$FilePath." HTTP/1.0\r\n\r\n";
$out = $Content = ""; socket_write ($socket, $in, strlen($in));
while ($out = socket_read ($socket, 2048))
{
$Content .= $out;
}
socket_close ($socket); $arrContent = split("\r\n\r\n",$Content,2);
//返回抓取回的内容
return $arrContent[1];