Iterate through table rows and print column text with Python Selenium

后端 未结 2 1079
我在风中等你
我在风中等你 2020-12-24 07:32

I have a table (

) with values in each row () from its body ().

The value I would lile to p

2条回答
  •  生来不讨喜
    2020-12-24 08:12

    The developer has put an ID into the table. I have it working now. It is printing all the cell values from column 2. The code is:

    table_id = self.driver.find_element(By.ID, 'data_configuration_feeds_ct_fields_body0')
    rows = table_id.find_elements(By.TAG_NAME, "tr") # get all of the rows in the table
    for row in rows:
        # Get the columns (all the column 2)        
        col = row.find_elements(By.TAG_NAME, "td")[1] #note: index start from 0, 1 is col 2
        print col.text #prints text from the element
    

提交回复
热议问题