程序员 centos Windows wordpress Android linux命令 开源 mysql google nginx HTML5 Ubuntu linux php 微软 shell apache Python Firefox 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"))

延伸阅读

评论