https://en.wikipedia.org/wiki/List_of_largest_companies_by_revenue
我想按收入顺序找出这些公司的名称。这有点挑战性,因为标题都有不同格式的标签。如果有人能想出解决办法,我将非常感激。你知道吗
我的问题的一个例子:
我想把“沃尔玛公司”和“中石化集团”等依次对应起来。你知道吗
<td><a href="/wiki/Wal-Mart_Stores,_Inc." title="Wal-Mart Stores, Inc."class="mw-redirect">Wal-Mart Stores, Inc.</a></td>
…在文件中。。。你知道吗
<td style="background: #ffffcc;"><a href="/wiki/Sinopec_Group" title="Sinopec Group" class="mw-redirect">Sinopec Group</a></td>
提前谢谢。你知道吗
这可以通过
beautifulsoup
轻松完成如果是单个字符串,那么可以使用
如果你还想用regex,那么
注意:-在第一组中匹配
Regex Demo
将
title
属性的内容分组到a
标记中。它检查是否是排名后的第一个表单元格。你知道吗目前已知它可以工作。但这是一个相当脆弱的方法。 查看Online Regex Tester查看regex详细信息
相关问题 更多 >
编程相关推荐