大佬教程收集整理的这篇文章主要介绍了关闭 selenium python 中的接受隐私模式,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试从该站点获取数据: https://marketsmithindia.com/mstool/evaluation.jsp#details/symbol/VIDHIING
在 SELEnium 中打开页面后,它会弹出“更新的隐私政策”窗口。我尝试在模态上使用等待并单击它,但它只是超时。这是我尝试过的代码:
click_button_path = "//[@class='modal-footer gdpr-notification-close']/[@class=''btn-priMary']"
wait = webdriverwait(driver,10)
click_button = wait.until(EC.visibility_of_element_located((By.XPATH,click_button_path)))
click_button.click()
后来我发现接受按钮被存储为 cookie,一旦接受就不会加载。所以我找到了一个迂回的方式。我在这里使用 Eduard 的回答保存了 cookie: How to save and load cookies using Python + SELEnium WebDriver
# You need to: from SELEnium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("user-data-dir=SELEnium")
driver = webdriver.Chrome(chrome_options=chrome_options)
driver.get("www.google.com") # Now you can see the cookies,the setTings,extensions,etc.,@R_801_6296@e logins done in the previous session are present here.
这并不完美,但解决了我的问题。
以上是大佬教程为你收集整理的关闭 selenium python 中的接受隐私模式全部内容,希望文章能够帮你解决关闭 selenium python 中的接受隐私模式所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。