我尝试在python中使用selenium访问多个标记的文本。你知道吗
标记没有id
或class
这样的属性;它们有一个名为itemprop
的属性。你知道吗
例如,有多个这样类型的标记:
<p itemprop="articleBody">
London's Gatwick Airport ........</p>
我不能使用“selectelementbytagname”,因为我不想包含具有不同属性的标记“p”。你知道吗
我使用下面的代码来选择这些元素:
elements = driver.find_element(By.CSS_SELECTOR, """p[itemprop='articleBody’]""")
但是它抛出错误-。。。。。。你知道吗
NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"p[itemprop='articleBody’]"}
我怎样才能解决这个问题?你知道吗
在选择器中有智能引号
’
,使用find_elements*
和s
来获取多个元素。你知道吗相关问题 更多 >
编程相关推荐