解决思路:对请求到的网页内容进行编码操作后再进行解码操作
r = requests.get(url, headers=headers)
r = r.text
# print(r)
# 对解析到的r内容r编码后再解码
r = r.encode('ISO-8859-1')
# utf-8或gbk或其他
r = r.decode('utf-8')
print(r)
html = etree.HTML(r)
title = html.xpath('//*[@class="title-prefix"]/text()')
点击网页内容改变url不变:
将network中动态js的请求地址做为真实url,进行网页解析
需要的html的url就都在网页了,json字符串转换,提取url