I am trying to Web-scrape the country names from the following page - http://hdr.undp.org/en/composite/trends
I am trying to get the Xpath of the particular element.
So for the first country, it appears like this -
Country = driver.find_element_by_xpath("//[@id='styleSheet.css']/div/div/div/div/table/tbody/tr[2]/td[2]").text
So basically for all the countries, I am using the For loop and range function in python.
for i in range(2,193):
try:
print(i)
Country = driver.find_element_by_xpath("//[@id='styleSheet.css']/div/div/div/div/table/tbody/tr["+int(i)+"]/td[11]").text
print(Country)
except Exception:
print("none")
But the problem is the X-path doesn't work for me. Kindly help me in locating the right element.
I resolved the first problem by changing the int to str as that was the error throwing up.After that it says cannot locate the current element.
except Exception as ethenprint(e)