更新时间:2022-11-03 21:47:57
添加以下代码段即可返回该页面:
Adding in the following code snippet got the page to return for me:
user_agent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.50 Safari/537.36'
chrome_options.add_argument('user-agent={0}'.format(user_agent))
该网站显然正在检查无头浏览器,然后拒绝它们访问.以下是有关避免检测的文章:使Chrome无法检测到无头
The site is obviously checking for headless browsers and then denying them access. Here's an article on avoiding detection: Making Chrome Headless Undetectable
要获取驱动程序正在使用的用户代理,可以运行以下命令:
To get the user agent being used by the driver you can run the following command:
driver.execute_script("return navigator.userAgent")
Chromes无头用户代理是这样的:
Chromes headless user agent is something like this:
u'Mozilla/5.0(Windows NT 10.0; Win64; x64)AppleWebKit/537.36(KHTML,像Gecko)HeadlessChrome/71.0.3578.98 Safari/537.36'
u'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/71.0.3578.98 Safari/537.36'