一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

php 模拟 post与浏览器请求数据

时间:2009-08-24 编辑:简简单单 来源:一聚教程网

] $host = "www.123cha.com";
$referer = "http://".$host;
$fp = fsockopen ($host, 80, $errno, $errstr, 30);
if (!$fp){
        echo "$errstr ($errno)
;n";
}else{
$request = "
GET / HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */"."*
Referer: http://$host
Accept-Language: zh-cn
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
Host: $host
Connection: Close"
."rnrn";


fputs ($fp, "$request");
while (!feof($fp))
{
   $res[] = fgets($fp,1024);
}
$html = join("",$res);
fclose ($fp);
$fp = file_put_contents("123cha.html",$html);
echo "done";
}[/

热门栏目