I am trying to get the pdf files from this website. I am trying to create a double loop so I can scroll over the years (Season) to get all the main pdf located in each year.
The line of code is not working is this one. The problem is, I can not make this line work (The one that is supposed to loop all over the years (Season):
for year in wait.until(EC.presence_of_all_elements_located((By.CSS_SELECTOR, "#season a aria-valuetext"))): year.click()
This is the full code:
os.chdir("C:..") driver = webdriver.Chrome("chromedriver.exe") wait = WebDriverWait(driver, 10) driver.get("http://www.motogp.com/en/Results+Statistics/") links = [] for year in wait.until(EC.presence_of_all_elements_located((By.CSS_SELECTOR, "#season a aria-valuetext"))): year.click() for item in wait.until(EC.presence_of_all_elements_located((By.CSS_SELECTOR, "#event option"))): item.click() elem = wait.until(EC.presence_of_element_located((By.CLASS_NAME, "padleft5"))) print(elem.get_attribute("href")) links.append(elem.get_attribute("href")) wait.until(EC.staleness_of(elem)) driver.quit()
This is a previous post where I got help with the code above: