使用soup.select(),返回類型是list
1、通過標簽名查找:soup.select('xxx_標簽名')
# 返回:符合該標簽名所有元素的列表
2、通過類名查找:soup.select('.xxx_類名')
3、通過id名查找:soup.select('#xxx_id名')
4、組合查找,查找xxx_標簽名下的xxx_類名,兩者之間需用空格分開:soup.select('xxx_標簽名 .xxx_類名')
5、通過子標簽查找:soup.select("head > title")
6、屬性查找:使用標簽查找時加入屬性元素,屬性需要用中括號,屬性和標簽屬於同一節點,所以不需要加空格
soup.select('xxx_標簽名[xxx_屬性="xxx"]')
soup.select('xxx_標簽名 xxx_標簽名[xxx_屬性="xxx"]')