I use Selenium and XPATH to extract all rows from a table, but I can only get the first row.
That's what I'm doing:
from selenium import webdriver path_to_chromedriver = '/Users/me/Desktop/chromedriver' browser = webdriver.Chrome(executable_path = path_to_chromedriver) url = "http://www.psacard.com/smrpriceguide/SetDetail.aspx?SMRSetID=1055" browser.get(url) browser.implicitly_wait(10) SMRtable = browser.find_element_by_xpath('//*[@class="set-detail-table"]/tbody') for i in SMRtable.find_element_by_xpath('.//tr'): print i.get_attribute('innerHTML') browser.close()
The SMRtable variable has all the lines in it when I convert to a string and print. When I try to get through it, it throws a not iterable error.
I also tried using browser.find_element_by_xpath('//*[@class="set-detail-table"]/tbody/tr') , but that only gives me the first line. I tried adding [position()>0] after /tr , but still only got the first line.
How can I get all the rows?
source share