I'm trying to scrape the "10 Year Australian bond" prices table on this website: https://www2.asx.com.au/markets/trade-our-derivatives-market/derivatives-market-prices/bond-derivatives
The following code works fine:
url='https://www2.asx.com.au/markets/trade-our-derivatives-market/derivatives-market-prices/bond-derivatives'
driver.get(url)
time.sleep(2)
id='onetrust-accept-btn-handler'
driver.find_element_by_id(id).click()
time.sleep(2)
driver.find_element_by_xpath('/html/body/div[1]/div/div[3]/div/div[1]/div/ul/li[3]').click()
id='tab-panel_17'
time.sleep(2)
tbl = driver.find_element_by_id(id).get_attribute('outerHTML')
soup = BeautifulSoup(tbl, 'html.parser')
aus_10y_future = pd.read_html(str(soup))[0]
In order to click on the "10 Year Australian bond" tab, I tried to use relative xpath insted of absolute one.
So, insted of
driver.find_element_by_xpath('/html/body/div[1]/div/div[3]/div/div[1]/div/ul/li[3]').click()
I tried:
driver.find_element_by_xpath('//*[contains(@class_name,"cmp-tabs__tabtitle")]/li[3]').click()
but I get an error. What am I doing wrong? Thanks