【问题标题】:How do you scrape even numbered <TD> elements with python/selenium?你如何用 python/selenium 刮掉偶数编号的 <TD> 元素?
【发布时间】:2019-11-30 08:07:22
【问题描述】:

我的目标代码如下所示:

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

问题是页面上有 50 个元素,每 5 个 TD 元素中,我只需要第二个。因此,例如元素 2、7、12、17 等。所有元素都没有任何类元素或 id,所以我能够定位它们的唯一方法是通过顺序,但我不知道如何通过硒。

【问题讨论】:

    标签: python selenium


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2021-03-11
      • 1970-01-01
      • 1970-01-01
      • 2021-03-17
      • 2019-08-10
      • 1970-01-01
      • 1970-01-01
      • 2021-10-16
      • 1970-01-01
      相关资源
      最近更新 更多