如何使用Python在Selenium Webdriver Chrome中启用JavaScript [英] How to enable javascript in selenium webdriver Chrome using python

查看:476
本文介绍了如何使用Python在Selenium Webdriver Chrome中启用JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Selenium Webdriver打开 https://www.guidestar.org/,但是能够检测到我是机器人.我收到的电子邮件说未启用javascript,因此它们阻止了我的IP地址.谁能建议一个代码来启用javascripts

I am trying to open https://www.guidestar.org/ using selenium webdriver but it is able to detect I am a bot. The email I received says that javascript was not enabled so they were blocking my IP address. Can anyone suggest a code to enable javascripts

user_agent = 'Chrome/73.0.3683.86'
username = os.getenv("USERNAME")
userProfile = "C:\\Users\\" + username + "\\AppData\\Local\\Google\\Chrome\\User Data\\Default"
options = webdriver.ChromeOptions()
options.add_argument(f'user-agent={user_agent}')
options.add_argument("user-data-dir={}".format(userProfile))
driver = webdriver.Chrome(chrome_options=options)
driver.get("http://www.guidestar.org")

我希望网站不要检测到我是机器人

I expected the website not to detect that I am a robot

推荐答案

此处提供的答案无效. 而是使用

answers provided here won't work. instead, use

    options.add_argument("--enable-javascript")

这篇关于如何使用Python在Selenium Webdriver Chrome中启用JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆