使用正则表达式过滤掉 div 元素的 style 属性
示例代码:
import re from bs4 import BeautifulSoup
html = """
soup = BeautifulSoup(html, "html.parser")
divs = soup.find_all("div", {"style": re.compile(r".*")}) for div in divs: # 在这里处理你要爬取的内容 print(div.text) # 输出:Hello World