Last active
December 27, 2015 00:09
-
-
Save nezuQ/7235661 to your computer and use it in GitHub Desktop.
Pixiv関連タグ検索
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
install.packages("RCurl") | |
library("RCurl") | |
my.keyword = "艦隊これくしょん 百合" | |
my.keyword.base = paste(my.keyword," 00Users入り", sep="") | |
my.keyword.hit = my.keyword | |
my.keyword.hit.c <- unlist(strsplit(my.keyword.hit," ")) | |
escapeURI <- function(uri){ | |
paste(sapply(unlist(strsplit(enc2utf8(uri), "")), | |
function(chr){ifelse((regexpr("\\W", chr, perl=TRUE)[1] > 0), | |
paste("%", charToRaw(chr), collapse="", sep=""), chr)}), collapse="") | |
} | |
pixiv.search.bytag <- function(keyword){ | |
data.df <- NULL | |
keyword.esc <- escapeURI(keyword) | |
for(i in 1:4){ | |
uri <- paste(paste(paste("http://spapi.pixiv.net/iphone/search.php?s_mode=s_tag&word=", keyword.esc, sep=""),"&PHPSESSID=0&p=", sep=""), i, sep="") | |
data.text <- getURI(uri) | |
if(0 < nchar(data.text)){ | |
data.csv <- gsub("\\\"","\"",data.text) | |
tmp <- tempfile() | |
cat(file = tmp,data.csv) | |
if(typeof(data.df) == "NULL"){ | |
data.df <- read.csv(tmp,header=FALSE,stringsAsFactors=FALSE) | |
}else{ | |
data.df <- rbind(data.df,read.csv(tmp,header=FALSE,stringsAsFactors=FALSE)) | |
} | |
} | |
} | |
data.df | |
} | |
pixiv.tag.2c <- function(value){ | |
strsplit(as.character(value)," ") | |
} | |
pixiv.search.usedtag <- function(keyword){ | |
data.raw.list <- pixiv.search.bytag(keyword) | |
if(class(data.raw.list) == "NULL"){ | |
NULL | |
}else{ | |
sapply(data.raw.list[,14],pixiv.tag.2c) | |
} | |
} | |
basetag.raw.list <- pixiv.search.usedtag(my.keyword.base) | |
basetag.c <- c() | |
for(x in basetag.raw.list){ | |
basetag.c <- append(basetag.c,x) | |
} | |
basetag.c.factor <- as.factor(basetag.c) | |
basetag.count <- tapply(basetag.c.factor, basetag.c.factor, length) | |
basetag.c.target <- names(basetag.count[basetag.count > 1]) | |
basetag.c.rate <- rep(0,length(basetag.c.target)) | |
names(basetag.c.rate) <- basetag.c.target | |
for(x in basetag.c.target){ | |
tag.list <- pixiv.search.usedtag(x) | |
if(class(tag.list) == "NULL"){ | |
#処理なし | |
}else{ | |
tag.list.count <- length(tag.list) | |
targettag.count <- 0 | |
for(y in tag.list){ | |
if(all(sapply(my.keyword.hit.c,function(z){any(y == z)}))){ | |
targettag.count <- targettag.count + 1 | |
} | |
} | |
basetag.c.rate[x] <- (targettag.count/tag.list.count) | |
} | |
} | |
basetag.c.rate[order(basetag.c.rate, decreasing = TRUE)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
愛高 ヘタレズ 二航戦 高雄姉妹 大北 赤賀 | |
0.85000000 0.57142857 0.25000000 0.23809524 0.21212121 0.13000000 | |
那智柄 ガチレズ大井bot 瑞加賀 大井(艦隊これくしょん) 大井 長陸奥 | |
0.12500000 0.11111111 0.10526316 0.09500000 0.07500000 0.05769231 | |
あぶきた 高雄 艦これ500users入り 天龍田 磯波 加賀(艦隊これくしょん) | |
0.05172414 0.05000000 0.04500000 0.04500000 0.03658537 0.03000000 | |
艦これ100users入り 山城 赤城(艦隊これくしょん) 艦コレまとめ キマシタワー ライン入りソックス | |
0.03000000 0.03000000 0.03000000 0.02898551 0.02500000 0.02500000 | |
阿武隈 愛宕 艦これ1000users入り 古鷹 女性提督 瑞鶴 | |
0.02500000 0.02500000 0.02500000 0.02000000 0.02000000 0.02000000 | |
赤城 比叡(艦隊これくしょん) 百合夫婦 扶桑 北上 龍田 | |
0.02000000 0.02000000 0.02000000 0.02000000 0.02000000 0.02000000 | |
涼風 唾液交換 ア艦これ 加賀 艦ぱい 胸合わせ | |
0.02000000 0.01652893 0.01500000 0.01500000 0.01500000 0.01500000 | |
金剛型 五月雨 今日も鎮守府は平和です 蒼龍 長門 天龍 | |
0.01500000 0.01500000 0.01500000 0.01500000 0.01500000 0.01500000 | |
比叡 飛龍 陸奥 泣ける艦これ 姉妹百合 提督LOVE | |
0.01500000 0.01500000 0.01500000 0.01000000 0.01000000 0.01000000 | |
白雪 艦これ 艦これかわいい 艦隊これくしょん 金剛(艦隊これくしょん) 榛名 | |
0.01000000 0.00500000 0.00500000 0.00500000 0.00500000 0.00500000 | |
瑞鳳 戦場の艦娘 大食艦 大破 木曾 夕張 | |
0.00500000 0.00500000 0.00500000 0.00500000 0.00500000 0.00500000 | |
キス なにこれかわいい メイキング希望 らくがき 響 金剛 | |
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 | |
雪風 千代田 島風 背後から胸揉み 百合 漫画 | |
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 | |
霧島 落書き | |
0.00000000 0.00000000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment