标签:enc decode mozilla div baidu utf-8 爬取 import pytho
# 引入扩展 from urllib import request, error, parse # 定义url、请求头、请求参数 url = "http://www.baidu.com" headers = {‘User-Agent‘: ‘Mozilla/5.0 3578.98 Safari/537.36‘} data = {‘wd‘: ‘python‘} #请求 data = parse.urlencode(data).encode(‘utf-8‘) url = request.Request(url, headers=headers, data=data) print(request.urlopen(url).read().decode(‘utf-8‘))
标签:enc decode mozilla div baidu utf-8 爬取 import pytho
原文地址:https://www.cnblogs.com/waterliang/p/12043573.html