Skip to content
Advertisement

how to get the href link of latest version only in Selenium python

I want the link of latest version of csv . If new version will come then I my program will pick latest href link.

Output :- https://www.nucc.org/images/stories/CSV/nucc_taxonomy_201.csv

 home_page1 = "https://www.nucc.org/index.php/code-sets-mainmenu-41/provider-taxonomy-mainmenu-40/csv-mainmenu-57"
driver = webdriver.Chrome("xx\xx\chromedriver.exe")
driver.get(home_page1)
elements = driver.find_elements_by_css_selector("li a")
for link in elements:
    print(link.get_attribute('href'))

enter image description here

Advertisement

Answer

iv looked at the website and its seems that you can do that by selenium “find_element_by_xpath”. iv attached a photo.enter image description here

so the right XPATH IS

//*[@id="main"]/div[2]/div/div/div[3]/div/ul[1]/li/a

please check if its working again when the new version is coming.

and then you can look for it with this command :

login_form = driver.find_element_by_xpath("//*[@id="main"]/div[2]/div/div/div[3]/div/ul[1]/li/a")

let me know if it was helful.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement