【发布时间】:2020-04-25 19:23:53
【问题描述】:
我正在关注本教程RSelenium and scraping 在我开始测试 navigate_click() 函数之前一切正常。 (set_names 与教程不同,因为我的源网站不同。)
navigate_click <- function() {
webElem <- remDr$findElement(using = "class name",
"google-visualization-table-div-page")
Sys.sleep(0.5)
webElem$clickElement()
remDr$getPageSource()[[1]] %>%
read_xml() %>%
xml_ns_strip() %>%
xml_find_all(xpath = '//td') %>%
xml_text() %>%
set_names(c("PublicationTitle", "County", "Place_of_Publication", "Library")) %>%
as.list() %>% as_tibble()
}
它返回一个错误:
read_xml.raw(charToRaw(enc2utf8(x)), "UTF-8", ..., as_html = as_html, 中的错误: xmlParseEntityRef: 没有名字 [68]
这是回溯...
> navigate_click()
Error in read_xml.raw(charToRaw(enc2utf8(x)), "UTF-8", ..., as_html = as_html, :
xmlParseEntityRef: no name [68]
11. read_xml.raw(charToRaw(enc2utf8(x)), "UTF-8", ..., as_html = as_html,
options = options)
10. read_xml.character(.)
9. read_xml(.)
8. function_list[[i]](value)
7. freduce(value, `_function_list`)
6. `_fseq`(`_lhs`)
5. eval(quote(`_fseq`(`_lhs`)), env, env)
4. eval(quote(`_fseq`(`_lhs`)), env, env)
3. withVisible(eval(quote(`_fseq`(`_lhs`)), env, env))
2. remDr$getPageSource()[[1]] %>% read_xml() %>% xml_ns_strip() %>%
xml_find_all(xpath = "//td") %>% xml_text() %>% set_names(c("PublicationTitle",
"County", "Place_of_Publication", "Library")) %>% as.list() %>%
as_tibble()
1. navigate_click()
【问题讨论】:
-
你能提供你的脚本代码吗?
-
我已经为上面的函数添加了代码。
-
我们需要您的源网站的 URL 来提供帮助。你能把它包括进去吗?