å£ã³ããããããã¤ãã®é度ãæ¯è¼ãã
ãããã¤ãããããã
ã¨ããããä¸ãã®é度ãé
ãããªããã°ããã
ã¨ãããã¨ã§å£ã³ããµã¤ãã®çµæããæ¯è¼ããã
以ä¸æ¸ããªããã³ã¼ãã
library(rvest) library(dplyr) library(tidyr) library(stringi) # 以ä¸ããã½ã¼ã¹ããã¦ã³ãã¼ã # http://netspeed.studio-radish.com/cgi-bin/netspeed/openresult/openresult.cgi dat <- read_html("~/downloads/result.html") numbers <- dat %>% html_nodes(xpath="//*[contains(@class,'graphmarker')]") %>% html_text() tags <- dat %>% html_nodes(xpath="//nobr") %>% html_text() detail <- dat %>% html_nodes(xpath="//*[contains(@class,'speeddata2')]") %>% html_text() result <- data.frame(type = tags[tags %in% c("ä¸ã","ä¸ã")], speed = gsub("Mbps|kbps", "", numbers) %>% as.numeric(), stringsAsFactors = FALSE) result$speed <- if_else(grepl("kbps",numbers),result$speed/1000, result$speed) # ä¸ãã®æã«ã¤ã³ã¯ãªã¡ã³ã i <- 0 result$num <- NA for(n in seq_len(nrow(result))){ if(result$type[n]=="ä¸ã"){ i <- i + 1 result$num[n] <- i }else{ result$num[n] <- i } } result_s <- result %>% spread(key=type, value=speed) result_s$detail <- gsub("\\n|\\t", "", detail) result_s$provider <- result_s$detail %>% stri_replace_first_regex(".+ãããã¤ã\\: (.*)測å®å°.+$","$1") result_s$provider <- ifelse(grepl("使ç¨åç·", result_s$provider), NA, result_s$provider) final <- result_s %>% group_by(provider) %>% summarise(count=n(), mean_ä¸ã=mean(ä¸ã), max_ä¸ã=max(ä¸ã), min_ä¸ã=min(ä¸ã), median_ä¸ã=median(ä¸ã), mean_ä¸ã=mean(ä¸ã), max_ä¸ã=max(ä¸ã), min_ä¸ã=min(ä¸ã), median_ä¸ã=median(ä¸ã) ) library(openxlsx) write.xlsx(final, "ãããã¤ãéæ¯è¼.xlsx")