【发布时间】:2021-11-09 04:38:13
【问题描述】:
我正在尝试抓取一张表格,而无论是谁设置它以将一堆信息放在一个单列表格中,并且在每一行内,都有很多行。
我想从行内抓取每个 for 并创建一个数据框,并将其作为一行。我还想将位于<strong> </strong> 中的信息设置为整个数据框的列。
有没有办法用 python 做到这一点?我一直在使用 selenium 和 pandas read_html,但我想我在这里碰壁了。最终,我想将所有这些信息整合到一个数据框中。
HTML 看起来像这样。
<td>
<strong> Important Information1 </strong>
<br> Some information
<br> Some information
<br> Some information
<br> Some information
<br> Some information
<br> Some information
</td>
<td>
<strong> Important Information 2 </strong>
<br> Some information 2
<br> Some information 2
<br> Some information 2
<br> Some information 2
<br> Some information 2
<br> Some information 2
<br> Some information 2
<br> Some information 2
<br> Some information 2
<br> Some information 2
</td>
<td>
<strong> Important Information 3 </strong>
<br> Some information 3
<br> Some information 3
<br> Some information 3
<br> Some information 3
</td>
预期结果:
Important Header Some Information Header
0 Important Information1 Some information
1 Important Information1 Some information
2 Important Information1 Some information
3 Important Information1 Some information
4 Important Information1 Some information
5 Important Information1 Some information
6 Important Information2 Some information 2
7 Important Information2 Some information 2
8 Important Information2 Some information 2
9 Important Information2 Some information 2
10 Important Information2 Some information 2
11 Important Information2 Some information 2
12 Important Information2 Some information 2
13 Important Information2 Some information 2
14 Important Information2 Some information 2
15 Important Information2 Some information 2
16 Important Information3 Some information 3
17 Important Information3 Some information 3
18 Important Information3 Some information 3
19 Important Information3 Some information 3
【问题讨论】:
标签: python selenium web-scraping beautifulsoup