无法从 Webelement Selenium Python 打印文本

坚定的abds

无法弄清楚如何让这个工作。我正在尝试从 XPath 元素获取文本。硒蟒

输入

put_action = driver.find_elements_by_xpath('//*[@id="chart"]/svg/g/g[7]/text[1]')
print(time_expented.text)
print(winning_rate.text)
for tx in put_action:
    print(tx.text)

输出

EUR/USD binary signal, expiry at 23:45
Recent EUR/USD binary signals, success rate : 80%

尝试其他代码

输入:

time_expented = driver.find_element_by_css_selector("h1")
winning_rate = driver.find_element_by_css_selector("h2")
put_action = driver.find_elements_by_xpath('//*[@id="chart"]/svg/g/g[7]/text[1]')
print(time_expented.text)
print(winning_rate.text)
    print(put_action.text)

输出:

EUR/USD binary signal, expiry at 0:00
Recent EUR/USD binary signals, success rate : 80%
Traceback (most recent call last):
  File "/home/mint/Documents/scraper/main.py", line 63, in <module>
    main()
  File "/home/mint/Documents/scraper/main.py", line 14, in main
    eurousd()
  File "/home/mint/Documents/scraper/main.py", line 44, in eurousd
    print(put_action.text)
AttributeError: 'list' object has no attribute 'text'

这从这里抓取数据

报废元素

HTML 格式

预言家

svggrect等特殊图形元素的标签名称。它们可以以特殊方式处理,类似于元素文本内容。
代替

put_action = driver.find_elements_by_xpath('//*[@id="chart"]/svg/g/g[7]/text[1]')

尝试这个:

put_action = driver.find_elements_by_xpath('//*[@id="chart"]/*[name()="svg"]/*[name()="g"]/*[name()="g"][7]/*[name()="text"][1]')

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何使用Selenium检索WebElement的文本-Python

Python Selenium TypeError:无法连接“ str”和“ WebElement”对象

Python / Selenium-无法打印所有段落的文本内容

Python以及如何从Selenium元素WebElement对象获取文本?

从Selenium WebElement中提取文本

迭代Selenium / Python中的WebElement

从 Element Selenium Python 打印文本

Python Selenium WebElement元素-无效的语法

如何在python中导入Selenium WebElement

使用 selenium Python 循环遍历 webelement

Selenium / Python TypeError:“ WebElement”对象不可迭代

Python Selenium无法打印整个页面

Selenium Python:不打印元素文本

Python + Selenium -- 打印出文本

Selenium + Python:打印元素的文本属性

python selenium,无法检索xpath的文本

Selenium Webdriver 3.7中无法单击按钮(WebElement)

打印文本框中的文本 PYTHON Selenium

无法在python中打印描述文本

在Selenium测试中使用XPath通过文本获取WebElement

Python Selenium-检查一个WebElement是否等于另一个WebElement

如何在Python Selenium中获取WebElement的类名?

使用 Python Selenium 抓取空的 Webelement 时获取 TimeoutException

使用Python在Selenium WebDriver中获取WebElement的HTML源

使用Python在Selenium WebDriver中获取WebElement的HTML源

使用Python和JavaScript通过Selenium使WebElement可见

使用Python重写Selenium中的webElement的.click()方法

如何在python selenium中使用style属性查找webelement

如何在Python中使用Selenium Webdriver提取Webelement