网页爬虫 - python爬虫打印HTML问题
PHP中文网
PHP中文网 2017-04-18 10:00:33
0
2
501
PHP中文网
PHP中文网

认证高级PHP讲师

Antworte allen(2)
迷茫

"User-Agent": "Mozilla/5.0 (windows 6.0)"

python3

import urllib.request
url = "http://www.qiushibaike.com/8hr/page/1"
headers = {
    #"User-Agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N)"
    "User-Agent": "Mozilla/5.0 (windows 6.0)"
}
request = urllib.request.Request(url, headers=headers)
response = urllib.request.urlopen(request)
c = response.read()
h = c.decode('utf-8')
print(h)
伊谢尔伦

python3 不需要转码



我又尝试了以下。发现response.decode('UTF-8')就可以。是的大写!!!
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage