我想使用 URL 地址作为文件名而不是“i”。认为这是小菜一碟,只是links[i,0]
在写函数中而不是“i”,但它似乎不起作用。
library(RCurl)
library(foreach)
library(foreign)
links <- read.table("CSV FILE WITH N LINKS", header = T, quote = "\"")
outpath <- "RANDOM FOLDER"
foreach(i = 1:nrow(links)) %do% {
text <- getURL(links[i,]) print(i)
write(as.character(text), file = paste(outpath, "/", i, ".txt", sep = ""))}
我收到以下错误:
10: In file(file, ifelse(append, "a", "w")) :
cannot open file '/Users/kasper2304/Desktop/Lego test/Star Wars output/http://news.lugnet.com/starwars/?n=10.txt': No such file or directory