there are some elements with different xpath like 'code' in the website:
.td[1]/div[4]/div
.td[1]/div[3]/div
null
if the xpath = .td[1]/div[4]/div, then there should be another ISIN code in .td[1]/div[3]/div I want to access them all with:
driver.get('https://www.chinabondconnect.com/en/Primary/Primary-Information/Onshore.html')
wait = WebDriverWait(driver, 30)
driver.find_element_by_link_text('Others').click()
try:
codes=[code.get_attribute('textContent') for code in driver.find_elements_by_xpath("//table[@id='tb7']//tr[starts-with(@class,'tb2tr pg')]//td[1]/div[4]/div")]
ISINs=[ISIN.get_attribute('textContent') for ISIN in driver.find_elements_by_xpath("//table[@id='tb7']//tr[starts-with(@class,'tb2tr pg')]//td[1]/div[3]/div")]
except:
try:
codes=[code.get_attribute('textContent') for code in driver.find_elements_by_xpath("//table[@id='tb7']//tr[starts-with(@class,'tb2tr pg')]//td[1]/div[3]/div")]
except:
codes = 'null'
#dateframe=...
But it will not return all issuers in the website, only just few ones, not sure why this happened, any help will be appreciated!
("//table[@id='tb7']//tr[starts-with(@class,'tb2tr pg')]//td[3]/div[3]/span[2]")ordiv[5], not sure how to deal with that situation..