84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
今天在学习bs4的解析html中 发现有解析各种标签中的内容的语句,但是未找到能解析出h1 h2 h3 h4这些标签中的文字的语句和参数啊,请问该如何进行筛选呢?
光阴似箭催人老,日月如移越少年。
>>> from bs4 import BeautifulSoup >>> html = """ <html> <h1 align="center">This is heading 1</h1> </html> """ >>> soup = BeautifulSoup(html,'html.parser') >>> res = soup.find('h1').get_text() >>> print(res) This is heading 1
Like this?
h1.string
Like this?
h1.string