我正在尝试使用Python2.7中的BeautifulSoup(bs4)包在html文档中查找以下标记:
<div style="position:absolute; border: textbox 1px solid; writing-mode:lr-tb; left:408px; top:540px; width:14px; height:9px;"><span style="font-family: OEULZL+ArialMT; font-size:9px">0.00<br></span></div>
Run Code Online (Sandbox Code Playgroud)
在html文档中,还有多个其他标签几乎完全相同 - 唯一一致的区别是"left:408px"和"height:9px"属性.
我怎样才能找到这个标签BeautifulSoup?
我尝试过以下方法:
from bs4 import BeautifulSoup as bs
soup = bs("<div style="position:absolute; border: textbox 1px solid; writing-mode:lr-tb; left:408px; top:540px; width:14px; height:9px;"><span style="font-family: OEULZL+ArialMT; font-size:9px">0.00<br></span></div>", 'html.parser')
soup.find_all('div', style=('left:408px' and 'height:9px'))
soup.find_all('div', style=('left:408px') and style=('height:9px')) #doesn't like style being used twice
soup.find_all('div', {'left':'408px' and 'height':'9px'})
soup.find_all('div', {'left:408px'} and {'height:9px'})
soup.find_all('div', style={'left':'408px' and 'height':'9px'})
soup.find_all('div', style={'left:408px'} and {'height:9px'})
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?