Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/330.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用selenium在网站上获取访问类信息_Python_Selenium - Fatal编程技术网

Python 使用selenium在网站上获取访问类信息

Python 使用selenium在网站上获取访问类信息,python,selenium,Python,Selenium,我使用Python 3.6和selenium使用以下代码: element = driver.find_element_by_class_name("first_result_price") print(element) 在网站上是这样的 `网站:span class=“第一次结果价格”>712 然而,如果我打印元素,我会得到一个完全不同的数字 有什么建议吗 非常感谢 “元素”是Selenium添加的一种称为WebElement的对象类型。如果你想在元素中找到文本,你必须说 element.t

我使用Python 3.6和selenium使用以下代码:

element = driver.find_element_by_class_name("first_result_price")
print(element)
在网站上是这样的

`网站:span class=“第一次结果价格”>712 然而,如果我打印元素,我会得到一个完全不同的数字

有什么建议吗

非常感谢

“元素”是Selenium添加的一种称为WebElement的对象类型。如果你想在元素中找到文本,你必须说

element.text

虽然是字符串形式,但它应该返回您想要的“712”。

我想我们需要了解更多。一个猜测:至少还有一个元素存在于该类名中。另一个可能性是:网页随着时间的推移而变化。谢谢各位,如果我在网站上搜索,我只会发现类“port”,我刚刚再试了一次,它看起来是一样的。你不会给我们url,是吗?很多thans Menix,不幸的是,如果我使用element.text,我会得到“”仅?您能否提供网站的url和此HTML元素的位置?它可能不会实际显示在页面上,在这种情况下,您可能必须引用WebElement对象的其他属性。url为: