I already spend a week trying to figure out how to dismiss the "accept cookies" popup that keeps freezing my code.I borrowed the code from here and transformed it a bit to meet my needs.I searched the site but almost nothing to seem like my case.I m posting the portion of the code that causes the problem.Any help will be appreciated.
from selenium import webdriver
from selenium.webdriver.opera.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from time import sleep
from datetime import datetime
import pandas as pd
errors = []
season = []
for id in range(2124889, 2124890):
# Opening the connection and grabbing the page
my_url = f'https://www.lefigaro.fr/sports/football/live/bundesliga/2020/{id}/*'
option = Options()
option.headless = False
driver = webdriver.Opera(options=option)
driver.get(my_url)
driver.maximize_window()
WebDriverWait(driver,10).until(EC.frame_to_be_available_and_switch_to_it((
By.XPATH,'//iframe[@id="appconsent"]')))
WebDriverWait(driver,10).until(EC.element_to_be_clickable((
By.XPATH,'//button[contains(@title,"Tout Accepter")]'))).click()
sleep(5)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…