BeautifulSoup: Find table by style

心不动则不痛 提交于 2020-01-13 11:36:06

问题


Is it possible to find a specific table with unique style?

Say, given the following html:

<table border="1" style="background-color:White;font-size:10pt;border-collapse:collapse;">

How can I use BS to find that table?

Thanks


回答1:


Try it:

from bs4 import BeautifulSoup
bs = BeautifulSoup(htmlcontent)
bs.find_all('table', attrs={'border': '1' ,'style':'background-color:White;font-size:10pt;border-collapse:collapse;'})

Check this link for more details.



来源:https://stackoverflow.com/questions/23584658/beautifulsoup-find-table-by-style

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!