Py学习  »  Python

如何使用selenium和python在dd属性中提取没有名称的文本?

Bob Stone • 7 年前 • 2064 次点击  

我有一个带有dd值的网页。代码如下:

<dd itemprop="youSave" 
class="saleprice pricingSummary-priceList-value" 
style="width: 50%; height: 20px; text-align: left; padding-left: 8px; line-height: 16px;">
$467.99</dd>

如何使用selenium和python拉取价格(467.99美元),同时去掉美元符号?

这是我当前的代码,它提取保存的价格,但无法获取属性:

try:
    while True:
        price_saved = driver.find_elements_by_xpath("//dl[@class='dl']//dd")
        print("ok")
        saved_print = price_saved.get_attribute("*Don't know what to put here*")
        print("k")
        print(saved_print)
        i = i + 1
except:
    print("failed")
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/46071
文章 [ 1 ]  |  最新文章 7 年前