简体   繁体   中英

How do you scrape even numbered <TD> elements with python/selenium?

Code that I am targeting looks like this:

<td>
     <b>Shipwreck</b>: Fairfax the Deckhand
     <br>
     <b>Harpoon Harry's</b>: Franchisco Corvallio<br>
</td>

The issue is there are 50 elements on the page, out of every 5 TD elements, I only need the second one. So for example element 2, 7, 12, 17, etc. All of the elements do not have any class elements or id's so the only way that I am able to target them is through order but I am not sure how to do that through selenium.

那将是: find_by_css_selector('td:nth-child(5n+2)')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM