Xiaotao Shen

爬取MassBank数据

2018/04/20 Share

利用R语言爬去MassBank数据库

直接把代码记录如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
library(rvest)
url <- "http://www.massbank.jp/SVN/OpenData/record/Athens_Univ/"
met.id <- read_html(url)
met.id <- html_text(met.id)
met.id <- strsplit(x = met.id, split = "\n")[[1]]
met.id <- met.id[grep(".txt", met.id)]
met.id <- stringr::str_trim(met.id)
athens_univ <- vector(mode = "list", length = length(met.id))
for(i in 1:length(athens_univ)){
cat(i, " ")
temp.url <- paste("http://www.massbank.jp/SVN/OpenData/record/Athens_Univ/", met.id[i], "/", sep = "")
met.ms2 <- read_html(temp.url)
met.ms2 <- html_text(met.ms2)
met.ms2 <- strsplit(x = met.ms2, split = "\r\n")[[1]]
athens_univ[[i]] <- met.ms2
}
names(athens_univ) <- gsub(pattern = ".txt", replacement = "", x = met.id)
CATALOG
  1. 1. 利用R语言爬去MassBank数据库