BeautifulSoup 删除标签而不删除内容(unwrap())
from bs4 import BeautifulSoupsoup = BeautifulSoup(body, 'html.parser')b = soup.findAll('a')for a in b: # 判断a标签里是否存在‘href’属性 if 'href' in a.attrs: href = a['href'] # 删除a标签,但不删除子节点或内容 a.unwrap()...