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

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

延伸阅读

评论