[英]How to enable javascript in selenium webdriver Chrome using python
I am trying to open https://www.guidestar.org/ using selenium webdriver but it is able to detect I am a bot. 我正在尝试使用selenium webdriver打开https://www.guidestar.org/,但它能够检测到我是机器人。 The email I received says that javascript was not enabled so they were blocking my IP address.
我收到的电子邮件说未启用javascript,因此它们阻止了我的IP地址。 Can anyone suggest a code to enable javascripts
谁能建议一个代码来启用javascript
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 我希望该网站不会检测到我是机器人
如supputuri所述,在您的参数中添加以下chrome选项:
options.add_argument("javascript.enabled", True)
answers provided here won't work. 这里提供的答案无效。 instead, use
相反,使用
options.add_argument("--enable-javascript")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.