java 程序员 Python 微软 wordpress 开源 linux HTML5 nginx centos Ubuntu Firefox google php Android shell Windows apache linux命令 mysql

Python 读取中文网页

# coding=gbk
import http.client
import codecs

conn = http.client.HTTPConnection("www.baidu.com")
conn.request("GET","/index.html")
r1 = conn.getresponse()
print(r1.status, r1.reason)
print(r1.getheaders())
data1 = r1.read(102400)
print( data1.decode("gbk"))

延伸阅读

评论