library(ggplot2)
library(jsonlite)
library(dplyr)
#######
bus<-c("X","X","X","X","X","X","Y","Y","Y","Y","Y","Y")
busstop<-c("A","A","B","C","D","E","A","A","B","C","D","E")
time<-c("2018/1/5 08:58","2018/1/5 08:59","2018/1/5 09:01","2018/1/5 09:02","2018/1/5 09:05","2018/1/5 09:15","2018/1/5 08:40","2018/1/5 08:55","2018/1/5 09:02","2018/1/5 09:03","2018/1/5 09:05","2018/1/5 09:15")
df307<-data.frame(bus,busstop,time)
my.plotA <- ggplot(df307, aes(busstop,time, group = bus)) +
geom_line(aes(colour = bus), linetype = 2)
my.plotA
url<-"D:/Kimi Lin/Downloads/GetBusEvent/GetBusEvent"
data307<-fromJSON(url)
head(data307)
w<-data.frame(data307[["BusInfo"]])
x<-filter(w,w$RouteID=="108640")
a<-data.frame(StopID=x$StopID,
DataTime=x$DataTime,
BusID=x$BusID)
my.plotA <- ggplot(a, aes(StopID,DataTime, group = BusID)) +
geom_line(aes(colour = BusID), linetype = 2)
my.plotA
for (j in 1:3)) {
#爬出該按鈕對應的下載網址 指定為flink
url<-"https://tcgbusfs.blob.core.windows.net/blobbus/GetBusEvent.gz"
dlist<-fromJSON(url)
data<-data.frame(dlist[["BusInfo"]])
if (j==1){
df<-data
}else{
df <- rbind(df, data)
}
#照樣要稍稍暫停 這部分計有500多份網頁要進 要注意
Sys.sleep(60)
}#迴圈結束