我有一个链接列表,指向每个包含数据集和图形可视化效果的网页。我想创建一个可以访问每个页面并下载数据集的R代码。
例如在此链接上的:http://burkinafaso.opendataforafrica.org/ajcalpd/accidents-de-la-circulation-constat%C3%A9s-par-la-gendarmerie-nationale 在右侧菜单中选择数据集后,将显示该数据集。例如:https://drive.google.com/file/d/1ffUfEVkIawmLiLRJariBP_DNCoyuHr9q/view
当我使用R download.File 函数时,它将向我发送html(xml)内容。
例如,这里是列表中的前三(3)个链接:
[3]“ http://burkinafaso.opendataforafrica.org/unlnaq/activité-et-chômage-à-ouagadougou-en-2001”
这是我下载第一个链接中包含的数据集的代码。
link <- 'http://burkinafaso.opendataforafrica.org/ajcalpd/accidents-de-la-circulation-constatés-par-la-gendarmerie-nationale'
downloadImages <- function(files, name, outPath){
for(i in 1:length(files)){
download.file(files, destfile = paste0(outPath, "/", name, "_", i, ".txt"), mode = 'wb')
}
}
outPath="E:/opendata"
name="data"
downloadImages(link,name, outPath)
最后,我想在(csv,json或excel,...)的每个链接上下载数据。