用soup.select方法
# panel节点内部的panel—heading节点
print(soup.select('.panel .panel-heading'))
# ul里面的li
print(soup.select('ul li'))
# id为list-2的内部element节点
print(soup.select('#list-2 .element'))
print(type(soup.select('ul')[0]))
# ul下的li
print(soup.select('ul>li'))
# 获取属性
for ul in soup.select('ul'):
print(ul['id'])
print(ul.attrs['id'])
# 获取文本
for li in soup.select('li'):
print('Get Text:', li.get_text())
print('String:', li.string)