我在做一个网页抓取项目
当我运行代码时:
url = myurl
session = requests.session()
response = session.get(url)
print(response.content)
response.content如下所示:
<html><head><meta charset="utf-8"><script>function i700(){}i700.F20=function (){return typeof i700.O20.p60==='function'?i700.O20.p60.apply(i700.O20,arguments):i700.O20.p60;};i700.X70=function (){return typeof i700.v70.p60.............................
使用Firefox开发工具查看源网页,我找到了需要的数据
经过一些研究,我找到了解决办法。 我注意到,我的目标网站可以将Selenium检测为机器人,即使没有应用自动化
因此,为了在不被检测到的情况下访问此类网页,我找到了一个解决方案,使用ChromeOptions()类添加一些参数:
资料来源: Selenium webdriver: Modifying navigator.webdriver flag to prevent selenium detection
你给出的回答似乎不是gziped
response.content
将以binary byte-string的形式返回响应,这可能不是您想要的为了获得纯文本响应,您需要使用} 在字符串中搜索所需的元素
response.text
。从那里,您应该能够使用^{资料来源:requests documentation
相关问题 更多 >
编程相关推荐