执行脚本的结果:

./expect
spawn telnet www.eduu.com 80
GET / HTTP/1.1
Host: www.eduu.com
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.6)
Gecko/20100627 Firefox/3.6.6 GTB7.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-cn,zh;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: GB2312,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive


Trying 210.51.17.57...
Connected to www.eduu.com.
Escape character is '^]'.
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Tue, 20 Jul 2010 01:15:16 GMT
Content-Type: text/html
Transfer-Encoding: chunked
Connection: keep-alive
Keep-Alive: timeout=20
Location: http://www.sina.com/

b2
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx</center>
</body>
</html>

0


在 2010年7月19日 下午9:19,Chen Xing <cxcxc...@gmail.com>写道:

> 在 2010年7月19日 下午8:54,Tao Wang <dancef...@gmail.com> 写道:
>
> >
> >
> > 禁用全部脚本呢?
> >
> > wget 和其它的浏览器不同的地方是 wget 不支持脚本。
> >
>
>
> 与脚本无关,我前面已经发过一个例子,本以为已经说明了问题……HTTP服务器对不同的Header处理有所不同。我发个简单的expect脚本吧,大家去可以测试一下:
>
> #! /bin/expect
> spawn telnet www.eduu.com 80
> send "GET / HTTP/1.1\r"
> send "Host: www.eduu.com\r"
> send "User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.6)
> Gecko/20100627 Firefox/3.6.6 GTB7.1\r"
> #send "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-CN;
> rv:1.9.2) Gecko/20100115 Firefox/3.6.6\r"
> send "Accept:
> text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r"
> send "Accept-Language: zh-cn,zh;q=0.5\r"
> send "Accept-Encoding: gzip,deflate\r"
> send "Accept-Charset: GB2312,utf-8;q=0.7,*;q=0.7\r"
> send "Keep-Alive: 115\r"
> send "Connection: keep-alive\r"
> send "\r"
> send "\r"
> expect EOF
>
> 不知邮件会不会自己断行,如果有自动断行,请把行连回来。上面的代码在我这儿得到301,跳转到sina,不知道是不是所有人都这样?请尝试。
>
> 而如果把注释对换,即红行加注释,绿行去掉注释,就会得到原网站的页面。
>
>
> 从这个现象看,应该是服务器设置的问题。前面有朋友说是CDN,可惜我不太了解,但感觉CDN应是比HTTP底层的东西,该现象还是出在HTTP层,不应该在更底的层了。
>
> 但愿附了代码,问题能说明白。。
>
> > --
> > Regards
> >
> > Tao Wang
> >
>
>

回复