从r中的URL获取数据

时间:2017-05-30 05:00:54

标签: html r web

我想从此网址中获取详细信息(包含“exon”的行)

https://www.ncbi.nlm.nih.gov/nuccore/NM_002117.5

我尝试使用以下命令: -

url <- "https://www.ncbi.nlm.nih.gov/nuccore/NM_002117.5"    
resp <- GET(url)    
content(resp) 

但是,我无法访问数据。

1 个答案:

答案 0 :(得分:0)

如果您想查看该文件本身,您可以随时下载它:

fileUrl <- "https://www.ncbi.nlm.nih.gov/nuccore/NM_002117.5"
download.file(fileUrl, "./NM_002117.5", method="curl")

我认为只有macOS才需要method =“curl”。这样,您就可以在文本编辑器中打开文件。这是你在提到你无法访问数据时指的是什么?

实际上,您在R中拥有数据,但它们是HTML内容。