import urllib2
from BeautifulSoup import BeautifulSoup
page = urllib2.urlopen('http://www.leeon.me');
soup = BeautifulSoup(page,fromEncoding="gb18030")
print soup.originalEncoding
print soup.prettify()
如果中文页面编码是gb2312,gb[......]
import urllib2
from BeautifulSoup import BeautifulSoup
page = urllib2.urlopen('http://www.leeon.me');
soup = BeautifulSoup(page,fromEncoding="gb18030")
print soup.originalEncoding
print soup.prettify()
如果中文页面编码是gb2312,gb[......]