Python Forum
How to get specific TD text via Selenium?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to get specific TD text via Selenium?
#1
I try to scrape a table and read specific TD in Table in each row. But for some reasons it fails at the last step. What I'm doing wrong?

content = driver.find_element_by_id("searchResultTable").find_elements_by_tag_name("tr")
for contents in content:
    pop(contents.find_elements_by_tag_name("td")[9].text, "Value of 9th")
this example works, but it's a bit lame to loop through every TD until the index match. There should be a way to contact a TD directly with [Index]

content = driver.find_element_by_id("searchResultTable").find_elements_by_tag_name("tr")
for contents in content:
    td = contents.find_elements_by_tag_name("td")
    for ind, ttd in enumerate(td):
        if ind == 9:
           pop(ttd.text, "Value of 9th")
Reply


Messages In This Thread
How to get specific TD text via Selenium? - by euras - May-14-2021, 08:26 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  selenium wait for text question Larz60+ 3 2,584 Oct-25-2021, 09:50 AM
Last Post: Larz60+
  Selenium innerHTML list, print specific value denis22934 2 3,306 Jun-14-2021, 04:59 AM
Last Post: denis22934
  With Selenium create a google Search list in Incognito mode withe specific location, tsurubaso 3 3,305 Jun-15-2020, 12:34 PM
Last Post: tsurubaso
  Selenium extract id text xzozx 1 2,142 Jun-15-2020, 06:32 AM
Last Post: Larz60+
  Getting text using Selenium WiPi 10 4,946 Apr-27-2020, 08:58 AM
Last Post: WiPi
  Web crawler extracting specific text from HTML lewdow 1 3,429 Jan-03-2020, 11:21 PM
Last Post: snippsat
  Selenium returning web element instead of desired text newbie_programmer 1 5,235 Dec-11-2019, 06:37 AM
Last Post: Malt
  Getting a specific text inside an html with soup mathieugrimbert 9 16,017 Jul-10-2019, 12:40 PM
Last Post: mathieugrimbert
  XML Parsing - Find a specific text (ElementTree) TeraX 3 4,096 Oct-09-2018, 09:06 AM
Last Post: TeraX
  webscraping - failing to extract specific text from data.gov rontar 2 3,231 May-19-2018, 08:01 AM
Last Post: rontar

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020