python - BeautifulSoup4的问题
PHP中文网
PHP中文网 2017-04-18 09:34:25
0
1
294

BeautifulSoup可以获取到页面中display为none的元素么

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(1)
PHPzhong

If display:none is specified with style in html, it can be obtained with BeautifulSoup.

print soup1.select( '[style~="display:none"]' )

Documentation: select method used CSS2 selectors: http://www.crummy.com/softwar...

However, the display:none in the page may also come from CSS rendering, or attributes dynamically added by js. In this case, these elements cannot be obtained using BeautifulSoup alone. You need to use selenium to parse it first, and then use BeautifulSoup to obtain it.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template