2.2.2python的BeautifulSoup库

from bs4 import BeautifulSoup
import re
broken_html = '<ul class="country"><li>Area<li>Population</ul>'
soup = BeautifulSoup(broken_html,'html.parser')
fixed_html = soup.prettify()
print(fixed_html)
print("\n")
ul = soup.find('ul', attrs={'class':'country'})
print(ul)

posted @ 2019-05-31 11:07  小菜鸡的梦想  阅读(201)  评论(0编辑  收藏  举报