【发布时间】:2018-10-12 17:43:49
【问题描述】:
我有一个包含多个列表的网站的源代码。现在我想将这些列表的信息提取成python中可用的格式。
例如,请参阅下面国家列表的第一个列表条目:
<ul class='checklist__list'>
<li class=' checklist__item' id='checklist__item--country-111'>
<label class='checklist__label ripple-animation'>
<input class="checklist__input js-checklist__input idb-on-change" type="checkbox" id="111" name="country" value="111">
Germany
</input>
</label>
</li>
说,我现在对国家 ID(此处:111)和匹配的国家/地区名称(此处:德国)感兴趣,并希望在 python 中以可用的格式使用它,例如 pandas 数据框或字典。
有没有人知道一个简单的方法来做到这一点?原始列表包含 >100 个国家/地区。
非常感谢您的建议!
【问题讨论】:
-
看起来漂亮的汤在这里很容易
标签: python html list pandas html-lists