Estoy tratando Scrapear otra Web , intente una solucion que me habian dado aqui(muy util ) de ejecutar el click desde JS , pero para esta nueva web no funciona adjunto codigo:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("start-maximized")
# chrome_options.add_argument('disable-infobars')
driver = webdriver.Chrome(options=chrome_options, executable_path=r"C:\ProgramData\Anaconda3\Lib\site-packages\selenium\webdriver\chrome\chromedriver.exe")
driver.get("https://www.mismarcadores.com/baloncesto/usa/nba/resultados/")
while True:
# WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[@class='btn btn-primary btn-lg']//span[@class='glyphicon glyphicon-play']"))).click()
WebDriverWait(driver, 50).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="live-table"]/div[1]/div/div/a'))).click()
Create = driver.find_element_by_xpath('//*[@id="live-table"]/div[1]/div/div/a')
driver.execute_script("arguments[0].click();", Create)
print("LOAD MORE RESULTS button clicked")
driver.quit()
por lo que veo , el error que recibo es que se ejecuta una sola vez el click y luego me da el error:
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element ... is not clickable at point (749, 698). Other element would receive the click: ...
Mi codigo quedo asi:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
from bs4 import BeautifulSoup
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("start-maximized")
chrome_options.add_argument('disable-infobars')
browser = webdriver.Chrome(options=chrome_options, executable_path=r"C:\ProgramData\Anaconda3\Lib\site-packages\selenium\webdriver\chrome\chromedriver.exe")
browser.get("https://www.mismarcadores.com/baloncesto/usa/nba/resultados/")
TIMEOUT = 5
last_height = browser.execute_script("return document.body.scrollHeight;")
while True:
browser.execute_script("window.scrollTo(0, document.body.scrollHeight);")
try:
#Click button
WebDriverWait(browser, 50).until(EC.element_to_be_clickable((By.CLASS_NAME, 'event__more'))).click()
print("LOAD MORE RESULT button clicked")
except:
pass
time.sleep(TIMEOUT)
new_height = browser.execute_script("return document.body.scrollHeight;")
if new_height == last_height:
break
last_height = new_height
Pero no funciona lamentablemente intente toda la semana , cambiando cosas , pero al parecer queda cargando y muchas veces no me devuelve el scroll , puede ser que la pagina tenga algun antibot o similar???