![]() |
|
首页 │ Apache │ Linux│ Java│ MySQL│ 注册│帮助 | |||
相关问题
以下是获取到的内容,怎么会有红色部分的那几个字符呢?
不应该有的啊
多了那几个字符地,我用explode("\r\n\r\n",$getCon,2)就无法分解出http头和具体的HTML源码了,郁闷
| QUOTE: |
| HTTP/1.1 200 OK Date: Sun, 16 Jul 2006 03:54:04 GMT Server: Apache/2.0.54 (Unix) PHP/4.4.2 mod_ssl/2.0.54 OpenSSL/0.9.7e mod_fastcgi/2.4.2 DAV/2 SVN/1.1.4 X-Powered-By: PHP/4.4.2 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: PHPSESSID=f92f15377c06413920171635fac09575; path=/ Vary: Accept-Encoding Connection: close Transfer-Encoding: chunked Content-Type: text/html 1f03 以下内容省略 |
PHP代码如下:
CODE: $url = 'http://www.sohu.com'; $purl = parse_url($url); $host = $purl['host']; $path = $purl['path']; if (isset($purl['query'])) $path.='?'.$purl['query']; $fp = fsockopen($host, 80, $errno, $errstr, 10); if (!$fp) { echo $errno.$errstr; } else { $out = "GET $path HTTP/1.1\r\n"; // $out.= "Accept: */*\r\n"; // $out.= "Accept-Language: zh-cn\r\n"; // $out.= "UA-CPU: x86\r\n"; // $out.= "Accept-Encoding: gzip, deflate\r\n"; $out.= "Referer: http://$host\r\n"; //$out.= "If-Modified-Since: Wed, 10 Aug 2005 09:52:06 GMT\r\n"; //$out.= "If-None-Match: \"56c8152b919dc51:ddd\"\r\n"; $out.= "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322)\r\n"; $out.= "Host: $host\r\n"; $out.= "Connection: Close\r\n"; //$out.= "Cookie: rtime=7; ltime=1124891230804; cnadmin=true\r\n"; $out.="\r\n"; fwrite($fp, $out); while (!feof($fp)) { $con.= fgets($fp, 1024); } fclose($fp); } echo $con; |
[ 本帖最后由 YourEyes 于 2006-7-16 12:09 PM 编辑 ]
提问者:YourEyes 08-22 08:08
答复

