小编thu*_*k88的帖子

使用 RSelenium 获取元素文本

我已经为以下几行代码苦苦挣扎了几个小时,但我似乎仍然没有接近解决方案。我的代码如下:

#create a list of all the question elements on the page
questions <- remDr$findElements(using = 'xpath', "//div[@class='question-text']")

#get the first question element in the list
question <- questions[1]

#get the text of the question element
question$getElementText()
Run Code Online (Sandbox Code Playgroud)

当我使用 RStudio 进行调试时,似乎“问题”列表中的所有“问题”元素都正确填充了;'question' 项被正确填充了列表中的第一个 'question' 元素;但是下一行代码的许多变体,旨在获取问题元素中的文本,似乎都失败了,给出了以下错误:

Error in evalq({ : attempt to apply non-function
Run Code Online (Sandbox Code Playgroud)

错误可能来自代码的不同部分,但可能性很小,因为注释掉该行似乎可以让其他一切正常工作。

我将非常感谢你们和女孩们可能提供的任何帮助。我正在使用 RSelenium 在 R 中编程 - 正如您可能会说的,我是 R 的新手,尽管我在其他环境中使用 Selenium 的经验非常有限。

预先感谢您的想法!

selenium r rselenium

3
推荐指数
1
解决办法
5464
查看次数

标签 统计

r ×1

rselenium ×1

selenium ×1