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

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"))

延伸阅读

评论

暂无评论

写评论