只要您有一個WKN或ISIN的列表,您可以運行它並讀取/下載文件。你也可以刮掉WKN/ISINs,但是從這個網頁會更加複雜,我假設你可以訪問這些信息。
library(XML)
wkn<-c("DBX0BT","865985") #some stock IDs (WKN) for your targets
date.F<-"12.5.2014" #from when for historical data
date.T<-"12.5.2015" #to when
for(j in 1:length(wkn)){
tg<-htmlParse(paste0("http://www.ariva.de/",wkn[j],"/historische_kurse")) #parse the historical webpage
atbts<-xpathSApply(tg,'//div[@class="content left abstand"]/input') #extract attributes for that stock so we can download it
secu<-sapply(atbts, function(x) xmlAttrs(x)['value'])[1] #security id (only relevant for downloading)
boerseid<-sapply(atbts, function(x) xmlAttrs(x)['value'])[2] #boerse id (only relevant for downloading)
#download, read and assign the values
assign(wkn[j],read.csv(paste0("http://www.ariva.de/quote/historic/historic.csv?secu=",secu,"&boerse_id=",boerseid,
"&clean_split=1&clean_payout=0&clean_bezug=1&min_time=",date.F,"&max_time=",date.T,"&trenner=%3B&go=Download"),
sep=";"))
write.csv(get(wkn[j]),paste0(wkn[j],".csv"))
}
嗨,你能解釋一下(或指出正確的方向)你如何計算出這個URL嗎?我正在用Firefox Inspector查看ariva頁面,但沒有提示這些參數,是嗎? –
我使用了Chrome瀏覽器,並通過右鍵單擊使用「檢查元素」。通過轉到「檢查元素」內的「網絡」選項卡,我可以看到「請求URL」和查詢參數。 – nadizan