我在HTML文档中有一个固定元素,我需要得到它的位置:
它的方法是什么?你知道吗
我试过:
from bs4 import BeautifulSoup
markup = open("myFile.html")
soup = BeautifulSoup(markup=markup.read(), features='html.parser')
markup.close()
spans = soup.find_all('span')
for sp in spans:
print(sp.get('style'))
它返回None
元素:
<span class="ocrx_word" id="word_1_304" title="bbox 1459 1183 1505 1205; x_wconf 77" contenteditable="true" style="font-family: sans-serif; position: fixed; left: 1459px; top: 1183px; width: 46px; height: 22px;">DC</span>
位置如下:
element.style {
font-family: sans-serif;
position: fixed;
left: 1459px;
top: 1183px;
width: 46px;
height: 22px;
}
使用
css selector
并搜索span tag with style
属性。你知道吗相关问题 更多 >
编程相关推荐