简体   繁体   English

我如何使用 selenium 接受这些 cookie?

[英]How can I accept this cookies using selenium?

I'm trying to scrape this website https://www.parkers.co.uk but for some reason I cannot seem to get past the cookies pop up, I've tried with this code我正在尝试抓取此网站https://www.parkers.co.uk但由于某种原因我似乎无法通过弹出的 cookie,我已经尝试使用此代码

cookies = driver.find_element_by_xpath('//*[@id="notice"]/div[5]/button[2]') cookies.click() cookies = driver.find_element_by_xpath('//*[@id="notice"]/div[5]/button[2]') cookies.click()

but it doesn't seem to be working, what can I do?但它似乎没有工作,我该怎么办?

Try this:尝试这个:

 iframe = driver.find_element_by_xpath("//iframe[@title='SP Consent Message']")
 driver.switch_to.frame(iframe)
 driver.find_element_by_xpath("//button[@title='Accept All']").click()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM