Filtering out HTML elements which have 'display:none' either as a tag attribute or in their CSS
问题 Let's say you have some html source that's been scraped with Selenium, and parsed with BeautifulSoup: from selenium import webdriver from bs4 import BeautifulSoup driver = webdriver.Firefox() driver.get(url) soup = BeautifulSoup(driver.page_source) Is there a way to remove, from the html code or the soup object, all elements which either have: 1.) the attribute style=display:none within the html tag source (i.e. <div style = 'display:none'>...</div> ) or 2.) have the display:none property