mercredi 20 janvier 2021

Python Selenium if elif not work when click links

I am trying to click all links (and get elements) in a specific date (like today), else quit if it is published (like yesterday).

I use if-elif to achieve it but the website just continue clicking links despite of date, please find my codes here:

Any help will be highly appreciated!

dates = [date.get_attribute('innerHTML') for date in driver.find_elements_by_xpath('')]
for date in dates:
     if date == '[01-20]':
        links = [link.get_attribute('href') for link in driver.find_elements_by_xpath('')]
        for link in links:
            driver.get(link)
        next_page = driver.find_element_by_link_text('')
        next_page.click()
     elif date != '[01-20]': 
       driver.close()

Aucun commentaire:

Enregistrer un commentaire