[python] BeautifulSoup处理script标签

mac2024-07-04  158

from bs4 import BeautifulSoup soup = BeautifulSoup(article_content,"html.parser") desc = soup.text+"..." for tag in soup.find_all(): if tag.name in ["script", "link"]: tag.decompose() soup.prettify()
最新回复(0)