from bs4 import BeautifulSouphtml
BeautifulSoup是一个类,继承了Tag类.每一个BeautifulSoup对象实例,经过html内容进行构建.以下:
bsObj=BeautifulSoup(urllib.request.urlopen(url).read())函数
BeautifulSoup有两个重要的函数,find和find_all,经过此2函数,能够在叶面中找到须要的tag。url
bs4中共有4种对象,分别是BeautifulSoup,Tag,NavigableString和Comment对象。spa
[获取Tag对象属性]
经过Tag.attrs['属性名']能够获取对应标签的相应属性。
htm