【发布时间】:2015-09-06 08:16:46
【问题描述】:
我正在尝试使用 Selenium 解析一些 html。问题是如果类名包含空格,它会引发 error。
这是我要搜索的标签:<p class="p0 ng-binding">text</p>
我已经尝试了这两个选项:
result.find_element_by_class_name('departure').find_element_by_css_selector('p.p0 ng-binding').text
result.find_element_by_class_name('departure').find_element_by_class_name('p0 ng-binding').text
>>> selenium.common.exceptions.InvalidSelectorException: Message: The given selector p0 ng-binding is either invalid or does not result in a WebElement. The following error occurred:
InvalidSelectorError: Compound class names not permitted
谁能给我一个提示?
【问题讨论】:
-
这是两个类名。
-
你知道如何找到班级吗?
标签: python html parsing selenium text