我用python编写了一个程序来自动从网站检索信息。但是它返回了很多响应消息,所以我看不到我的程序是如何处理的。我怎样才能关闭它?
部分代码
cookiejar = cookielib.LWPCookieJar()
cookie_support = urllib2.HTTPCookieProcessor(cookiejar)
opener = urllib2.build_opener(cookie_support, urllib2.HTTPHandler(debuglevel=1))
urllib2.install_opener(opener)
....
url = 'http://weibo.com/2344328334/fans'
header = {'User-Agent':'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36'}
req = urllib2.Request(url = url, headers = header)
result = urllib2.urlopen(req)
text = result.read()
部分输出
send: 'GET /2344328334/fans HTTP/1.1\r\nAccept-Encoding: ...'
reply: 'HTTP/1.1 302 Moved Temporarily\r\n'
header: Server: nginx
header: Date: Tue, 10 Sep 2013 03:54:02 GMT
header: Content-Type: text/html; charset=utf-8
header: Transfer-Encoding: chunked
header: Connection: close
header: Cache-Control: no-cache, must-revalidate
header: Expires: Sat, 26 Jul 1997 05:00:00 GMT
... other messages ...