# -*- coding: UTF-8 -*-
from bs4 import BeautifulSoup
html_sample = ‘ \
<html> \
<body> \
<h1 id = “title”>Hello World</h1> \
<a href =”#” class=”link”>this is link1</a> \
<a href = “# link2” Class = “link”>This is link2</a> \
</body> \
</html>’
soup = BeautifulSoup(html_sample,’html.parser’)
print(soup.text)
课时
5
用BeautifulSoup 剖析网页元素