- 论坛徽章:
- 0
|
使用 fsockopen获取的数据中怎么多出来几个字符???有经验的进来看看
以下是获取到的内容,怎么会有红色部分的那几个字符呢?
不应该有的啊
多了那几个字符地,我用explode("\r\n\r\n",$getCon,2)就无法分解出http头和具体的HTML源码了,郁闷
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>BT电影免费下载</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gbk">
<link href="./templates/itdoor/{$images}/style.css" rel="stylesheet" type="text/css">
</HEAD>
以下内容省略
PHP代码如下:
- $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;
复制代码
偶使用 Httplook这个软件去捕捉IE收到的信息时,根本没有这几个字符的
[ 本帖最后由 YourEyes 于 2006-7-16 14:08 编辑 ] |
|