check<-function(x) { library(rvest) day1<-Sys.Date() day2<-Sys.Date()-7 url<-paste("http://app.finance.ifeng.com/hq/trade/stock_zijin.php?code=sh",x,"&begin_day=",day2,"&end_day=",day1,sep="") web<-read_html(url) res<-web%>%html_table(fill=T)%>%as.data.frame res<-res[-length(res[,1]),] LastAll<-res[2,2] NowAll<-res[1,2] BeforeAll<-res[3,2] t<-data.frame(Code==x,BeforeAll,LastAll,NowAll) t[,1:4]<-lapply(t[,1:4],as.vector) g<-function(y){substring(y,1,nchar(y)-2)} t[,2:4]<-lapply(t[,2:4],g) t[,2:4]<-lapply(t[,2:4],as.numeric) m<-strsplit(as.character(Sys.time())," ")[[1]][2] y<-as.numeric(substring(m,1,2)) u<-as.numeric(substring(m,4,5)) nt<-ifelse(y<12,(y-9)*60+u-30,ifelse(y>14,240,ifelse(y>12,(y-11)*60+u,120))) TP<-round(nt/240,2) t$ExpectIn<-round(t$NowAll/TP,0) t$MP<-round(t$ExpectIn/t$LastAll,2) t$Sign<-ifelse(MP<-1,"sell","hold") print(t) }