如何使用selenium只提取外部标签

2024-05-20 13:16:22 发布

您现在位置:Python中文网/ 问答频道 /正文

我只想提取外部标签

<tr><td class="tdstyle"><b>Sub Sub Category</b></td><td class="tdstyle" style="font-weight:bold">U/s.482 Cr.p.c under sec.138 and 142</td></tr>
<tr><td colspan="4"><table class="B2U-article" style="width: 100%"><tbody><tr><td>IA Number</td><td>Filing Date</td><td>Advocate Name</td><td>Misc.Paper Type</td><td>Status</td><td>Prayer</td><td>Order Date</td><td>Order</td></tr><tr><td style="font-weight:bold">IA 1/2019</td><td style="font-weight:bold">19/07/2019</td><td style="font-weight:bold">J RAMMOHAN RAO</td><td style="font-weight:bold">Stay Petition</td><td style="font-weight:bold">Pending</td><td style="font-weight:bold"><a href="#" id="prayerlink" onclick="getPrayer(&quot;to stay the operation of the orders in CrI M P No 445/ 2019 in CrtANo 542/2019 On the file of the Court of XV Addl District and Sessions JudgecmXV Addl Metropolitan Sessions JudgecumII Addl Family Court, Ranga Reddy District at Kukatpally, for the offence punishable under section 138 of Negotiable Instruments Act, pending disposal of the above petition and pass&quot;)">IA PRAYER</a></td><td style="font-weight:bold">-</td><td></td></tr><tr style="color:green"><td style="font-weight:bold"> IASR 41174/2019</td><td style="font-weight:bold">18/07/2019</td><td style="font-weight:bold">J RAMMOHAN RAO (7615)</td><td style="font-weight:bold">Stay Petition</td><td style="font-weight:bold">PENDING FOR SCRUTINY</td><td></td><td></td><td></td></tr></tbody></table></td></tr>
basic_table_row_tags = driver.find_elements_by_xpath('//table[1]/tbody/tr')

通过使用上面的代码,我得到了所有的标签


Tags: andofthestyletable标签trclass
1条回答
网友
1楼 · 发布于 2024-05-20 13:16:22

你能试试这个://table[1]/tbody/tr[1]吗 这将给你所有的表格标题 要获得像“IA Number”这样的特定头,可以使用//table[1]/tbody/tr[1]/td[1]等等

相关问题 更多 >