Beautifulsoup库之处理子标签、后代标签、兄弟标签、父标签
from bs4 import BeautifulSoup
soup=BeautifulSoup(html,"html.parser")
一,处理子标签和后代标签(children)
soup.find("table",{"class":"wap"}).children
# 后代标签
soup.find("table",{"class":"wap"}).descendants()
二,处理兄弟标签
soup.find("table",{"class":"wap"}).tr.next_siblings
或
soup.find({"class":"wap"}).next_siblings
# 返回单个标签
soup.find("table",{"class":"wap"}).tr.next_siblings