然后我用正则表达式查找,结果是没有。
import re
import requests
from bs4 import BeautifulSoup
wurl = 'https://kg.qq.com/node/play?s=Csh28ZCb1MIU0Cfr&g_f=personal&appsource=&pageId=personalH5'
html_wurl = requests.get(wurl)
soup = BeautifulSoup(html_wurl.text, 'html.parser')
pattern = re.compile(r'display\s*:\s*none\s*\!\simportant\s*;')
hidden_elements = soup.find_all(lambda tag: tag.has_attr('style') and pattern.search(tag['style']))
for element in hidden_elements:
print(element)
我试图找到没有显示的元素,它们都是输出。但是我找不到任何!重要的元素。 有人可以告诉我哪里出错了