Home > Mobile >  selenium (in python) don't complete the page loading
selenium (in python) don't complete the page loading

Time:10-06

I'm trying to scrap this site: https://www.politicos.org.br/Ranking and my cell on jupyter notebook don't complete the loading. The page has a Cookies button to accept, but I can't figure out how I can click on it. And I don't know if this is the problem.

import re
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from time import sleep
options = Options()
options.add_argument('window-size=1000,800')
navegador = webdriver.Chrome(options=options)
navegador.get('https://www.politicos.org.br/Ranking')
sleep(3)
click_dep = navegador.find_element(By.XPATH, '//*[@id="__next"]/div[2]/div[1]/div[4]/button')
click_dep.click()
sleep(1)

I'm using python 3 on jupyter notebook, thanks for you attention.

CodePudding user response:

I found the HTML code for Cookies button : <button >Aceitar</button>

So you can easily write the code to click button.

navegador.find_element(By.XPATH, '//*[@]').click()
  • Related