1
我想解析網站的利率,但我不能從<td>
元素中取出數據。蟒蛇刮阿賈克斯內容
我寫的短代碼來測試它得到第1行數據TABEL:
from selenium import webdriver
driver = webdriver.Firefox()
driver.get('https://www.gpw.pl/wskazniki_spolek_full')
table = driver.find_elements_by_xpath("//table[@class='tab03']/tbody/tr")[4].text
print table
driver.quit()
和我得到的結果:
2 PLNFI0800016 141 08OCTAVA 42 786 848 44,07 63,86 2016-12-31 H 0,69 27,80 ---
,但我想通過所有<td>
<tr>
中的元素標記在所有表中,具有class='tab03'
table = driver.find_elements_by_xpath("//table[@class='tab03']/tbody/tr")
for el in table:
col_id = el.find_element_by_tag_name('td')[1].text
col_kod = el.find_element_by_tag_name('td')[2].text
print("{}".format(col_id, col_kod))
driver.quit()
,但我得到的錯誤:selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: td