如何查找文字'通过使用硒?
driver = webdriver.Chrome()
URL= 'https://modernhousevn.com/collections/new-arrival/products/giuong-ngu-mh-21'
driver.get(URL)
sleep(1)
des = wait.until(EC.visibility_of_element_located((By.XPATH, "//strong[text()='Chất liệu :']/.."))).get_attribute('innerText')
print(des)
我的预期结果是['khung:khunggỗtthông -vạtgiườnggỗthông','da puhoặcvảibốCaocấpnhậpkhẩu','usse:d40/35 theotiêuchuẩnxuchuẩnxutkhẩu'theotiênxutkhẩu'
] //i.sstatic.net/myzhk.png“ rel =“ nofollow noreferrer”>
driver = webdriver.Chrome()
URL= 'https://modernhousevn.com/collections/new-arrival/products/giuong-ngu-mh-21'
driver.get(URL)
sleep(1)
des = wait.until(EC.visibility_of_element_located((By.XPATH, "//strong[text()='Chất liệu :']/.."))).get_attribute('innerText')
print(des)
My expected result is ['Khung : Khung Gỗ thông - Vạt giường gỗ thông', 'Da PU hoặc vải bố cao cấp nhập khẩu', 'Mousse : D40/35 theo tiêu chuẩn xuất khẩu']
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
< p>
包含'chấtliệu'
,回到父母,< p>
,而父母的类不是面板 - 体
,回到父母< ul>
,在< ul>
输出
<p>
contain'Chất liệu'
, back to parent<p>
and parent's class is notpanel-body
, back to parent<ul>
, find all<li>
in the<ul>
output
替换下面的代码行。
Replace below lines of code.
尝试此XPath以找到包含它的文本
(by.xpath,“ // strong [包含(text(),'chấtliệu')]”);
希望它能起作用!
Try this xpath to find the text which contains it
(By.XPATH,"//strong[contains(text(),'Chất liệu')]");
hope it will work!