【发布时间】:2020-09-11 11:16:51
【问题描述】:
我想搜索以不同 id 开头但类相同的 html div:
<div id="alabama" class="sc-fzoxKX fmCwKG state-entry">
<div id="alaska" class="sc-fzoxKX fmCwKG state-entry">
我尝试使用
containers = page_soup.findAll("div", {"class":"sc-fzoxKX fmCwKG state-entry"})
但是当我通过编写len(containers) 进行测试时,它返回 0。
我也试过containers[0],但它返回的索引超出范围错误。
谁能告诉我如何搜索列表?
【问题讨论】:
-
这能回答你的问题吗? How to find elements by class
标签: python html beautifulsoup