select方法中传入多个css选择器,获取到最后一个
print(soup.select(".panel,.panel-body"))
元素选择器
print(soup.select("ul li"))
print(soup.select("#list-2"))
嵌套获取元素中的数据
for ul in soup.select("ul"):
for li in ul.select("li"):
print(li.string)
支持获取属性值
for ul in soup.select("ul"):
print(ul['id'])