加一句这个可以解决浏览器中乱码问题
fout.write('<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />')
fout.write('<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />')
2016-10-02
知道为什么你们只输出了一条记录吗?仔细看看百度百科链接的后缀【/view/21087.htm】,看清楚不是 .html ,犯错误的举个手吧
2016-10-02
Python 3.x 获取网页代码
import urllib.request
url = 'http://www.baidu.com'
request = urllib.request.urlopen(url)
html = request.read().decode('utf8')
print(html)
import urllib.request
url = 'http://www.baidu.com'
request = urllib.request.urlopen(url)
html = request.read().decode('utf8')
print(html)
2016-10-02