【发布时间】:2020-11-23 04:06:15
【问题描述】:
我将如何使用 BS4 和 python3 解析以下行?我想提取“BH”和“Bahrain”。
<li><input class="checkboxSelect2" name="countries[]" type="checkbox" value="BH"/> Bahrain</li>
我可以得到“Bahrain”,但我不能得到“BH”
for l in allCountries.findAll("li"):
print(l.value)
print(l.text)
l.text 将返回 Bahrain 但 l.value 无效并引发错误。
【问题讨论】:
-
请展示
allCountries如何获得它的价值。
标签: python python-3.x beautifulsoup