python编码搞得头都大了。求大大能给以个能同时搞定163,sohu,天涯社区这三个网站的程序

import urllib.request

fp = urllib.request.urlopen("http://www.163.com")
line = fp.readline()
while line:
  print(line)
  line = fp.readline()

用Python3 的urllib抓取天涯时总是显示乱码。而sohu的网页默认有事gzip压缩过的。
请问有没有通用的方法,就像chrome一样,直接显示出来人能看得懂的html源码的方法?

请不吝赐教!!

(另外。用print(fp.read()))时总是出错。提示“IOError: [Errno 12] Not enough space”,请问何解?)

python 3.2

作者: ydnhwan   发布时间: 2011-06-03

用urllib2试下。

作者: iambic   发布时间: 2011-06-04