0
点赞
收藏
分享

微信扫一扫

Python爬虫获取网页编码为“ISO-8859-1”,中文乱码

代码敲到深夜 2022-08-21 阅读 91


url = "https://www.tyhttp.com/free/page1/"
response = requests.get(url, verify=False)
response.encoding = response.apparent_encoding
tree=etree.HTML(response.text)
ip_list = tree.xpath('//div[@class="td td-4"]/text()')[3:]
duankou_list = tree.xpath('//div[@class="td td-2"]/text()')[5:]

举报

相关推荐

0 条评论