【发布时间】:2016-10-23 00:48:39
【问题描述】:
我正在使用 library_Beautiful Soup 在 python 中编写代码,我想选择这个标签(使用 CSS 选择器):
<div>
...
<div>
...
<div style=" height:80px; width:700px; ">
...
我正在尝试:
soup.select('div div div[style*="height:80px; width:700px"]')
(CSS 选择器在单引号内,即
'div div div[style*="height:80px; width:700px"]')
但这并没有选择任何标签。
我也试过了:
soup.select('div div div[style*="height:80px;"][style*="width:700px"]')
但这也行不通。
我不允许这样做:
soup.select('div div div[style=" height:80px; width:700px "]')
因为它引发了一个错误,指出这是一个无效的 css 选择器(不允许在开始双引号之后或在结束双引号之前使用空格)。
谁能给我推荐这个标签的正确 CSS 选择器?
【问题讨论】:
-
你能添加一个codepen或其他东西来演示你的代码吗?
标签: python css beautifulsoup