2024-04-19 21:23:23 发布
网友
访问此link
我想得到product material & care的细节。你知道吗
product material & care
Shell: 70% polyester, 30% wool Lining: 100% polyester Dry-clean.
我试过下面提到的代码,但它不适合我。你知道吗
self.browser.find_element_by_xpath("//h6[@class='pdp-product-description-title']/p").text
<p>标记是同级元素,而不是子元素。使用following-sibling::p
<p>
following-sibling::p
self.browser.find_element_by_xpath("//h6[@class='pdp-product-description-title']/following-sibling::p").text
这样试试。你知道吗
解释xpath:-使用<h6>标记和text方法开始xpath,然后使用following关键字继续使用<p>标记。你知道吗
<h6>
text
xpath
following
self.browser.find_element_by_xpath("//h6[contains(text(), 'Material & Care')]/following::p[@class='pdp-product-description-content']").text
OR
使用带有<p>标记的索引。你知道吗
self.browser.find_element_by_xpath("//h6[contains(text(), 'Material & Care')]/following::p[1]").text
<p>
标记是同级元素,而不是子元素。使用following-sibling::p
这样试试。你知道吗
解释xpath:-使用
<h6>
标记和text
方法开始xpath
,然后使用following
关键字继续使用<p>
标记。你知道吗使用带有
<p>
标记的索引。你知道吗相关问题 更多 >
编程相关推荐