修改r中全文检索的GET请求
我正在使用r软件包europepmc()和功能EPMC_FTXT用于获取给定PMC ID的某些文章的全文。但是,对于许多文章,我一直遇到以下错误:
“请求失败[404]。在1秒内重试... EPMC_FTXT中的错误(“ PMC2701033”): 找不到(HTTP 404)。未能检索全文。”
是因为本文不属于OpenAccess子集(我想)。但是我检查了一下,发现我的大学已获得访问该文章的许可。所以我的问题是。 ..如何在功能中编辑get请求,以便告诉EPMC_FTXT我可以实际访问该文章? 下面的代码:
#' Fetch Europe PMC full texts
#'
#' This function loads full texts into R. Full texts are in XML format and are
#' only provided for the Open Access subset of Europe PMC.
#'
#' @param ext_id character, PMCID.
#' All full text publications have external IDs starting 'PMC_'
#'
#' @export
#' @return xml_document
#'
#' @examples
#' \dontrun{
#' epmc_ftxt("PMC3257301")
#' epmc_ftxt("PMC3639880")
#' }
epmc_ftxt <- function(ext_id = NULL) {
if (!grepl("^PMC", ext_id))
stop("Please provide a PMCID, i.e. ids starting with 'PMC'")
# call api
req <-
httr::RETRY("GET",
base_uri(),
path = paste(rest_path(), ext_id,
"fullTextXML", sep = "/"))
# check for http status
httr::stop_for_status(req, "retrieve full text.")
# load xml into r
httr::content(req, as = "text", encoding = "utf-8") %>%
xml2::read_xml()
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论