用python3抓取中文网页

http://www.oschina.net/code/snippet_241930_9550

#! /usr/bin/python3.2
import sys
import urllib.request
req = urllib.request.Request('http://www.baidu.com')
response = urllib.request.urlopen(req)
the_page = response.read()   #byte类型
type = sys.getfilesystemencoding() #转换成本地系统编码
html=the_page.decode(type)   #str类型
print(html) 


你可能感兴趣的:(用python3抓取中文网页)