立即学习:https://edu.csdn.net/course/play/24756/280701?utm_source=blogtoedu
select:
from bs4 import BeautifulSoup
html=""" """
soup = BeautifulSoup(html,"lxml")
(1)通过标签名查找:
print(soup.select('a'))
(2)通过类名查找:
print(soup.select('.sister'))
(3)通过id查找:
print(soup.select('#link1'))
(4)组合查找:
print(soup.select('p #link1'))
或者:
print(soup.select('head > title'))
(5)通过属性查找:
print(soup.select('a[href=" "]'))
(6)获取内容:
print(soup.select('title')[0].get_text())