| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Woothee::Crawler; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 6 |  |  | 6 |  | 43 | use strict; | 
|  | 6 |  |  |  |  | 11 |  | 
|  | 6 |  |  |  |  | 173 |  | 
| 4 | 6 |  |  | 6 |  | 33 | use warnings; | 
|  | 6 |  |  |  |  | 11 |  | 
|  | 6 |  |  |  |  | 137 |  | 
| 5 | 6 |  |  | 6 |  | 30 | use Carp; | 
|  | 6 |  |  |  |  | 11 |  | 
|  | 6 |  |  |  |  | 337 |  | 
| 6 |  |  |  |  |  |  |  | 
| 7 | 6 |  |  | 6 |  | 32 | use Woothee::Util qw/update_map update_category update_version update_os/; | 
|  | 6 |  |  |  |  | 11 |  | 
|  | 6 |  |  |  |  | 381 |  | 
| 8 | 6 |  |  | 6 |  | 40 | use Woothee::DataSet qw/dataset/; | 
|  | 6 |  |  |  |  | 20 |  | 
|  | 6 |  |  |  |  | 8980 |  | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | our $VERSION = "v1.10.0"; | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | sub challenge_google { | 
| 13 | 1470 |  |  | 1470 | 0 | 2610 | my ($ua,$result) = @_; | 
| 14 |  |  |  |  |  |  |  | 
| 15 | 1470 | 100 |  |  |  | 7478 | return 0 if index($ua, "Google") < 0; | 
| 16 |  |  |  |  |  |  |  | 
| 17 | 72 | 100 |  |  |  | 254 | if (index($ua, "compatible; Googlebot") > -1 ) { | 
| 18 | 18 | 100 |  |  |  | 65 | if (index($ua, "compatible; Googlebot-Mobile") > -1) { | 
| 19 | 12 |  |  |  |  | 42 | update_map($result, dataset('GoogleBotMobile')); | 
| 20 | 12 |  |  |  |  | 45 | return 1; | 
| 21 |  |  |  |  |  |  | } | 
| 22 |  |  |  |  |  |  | else { | 
| 23 | 6 |  |  |  |  | 23 | update_map($result, dataset('GoogleBot')); | 
| 24 | 6 |  |  |  |  | 27 | return 1; | 
| 25 |  |  |  |  |  |  | } | 
| 26 |  |  |  |  |  |  | } | 
| 27 | 54 | 100 |  |  |  | 172 | if (index($ua, "Googlebot-Image/") > -1) { | 
| 28 | 6 |  |  |  |  | 23 | update_map($result, dataset('GoogleBot')); | 
| 29 | 6 |  |  |  |  | 39 | return 1; | 
| 30 |  |  |  |  |  |  | } | 
| 31 | 48 | 100 |  |  |  | 159 | if (index($ua, "Mediapartners-Google") > -1) { | 
| 32 | 12 | 50 | 66 |  |  | 69 | if (index($ua, "compatible; Mediapartners-Google") > -1 || $ua eq "Mediapartners-Google") { | 
| 33 | 12 |  |  |  |  | 34 | update_map($result, dataset('GoogleMediaPartners')); | 
| 34 | 12 |  |  |  |  | 47 | return 1; | 
| 35 |  |  |  |  |  |  | } | 
| 36 |  |  |  |  |  |  | } | 
| 37 | 36 | 100 |  |  |  | 105 | if (index($ua, "Feedfetcher-Google;") > -1) { | 
| 38 | 6 |  |  |  |  | 26 | update_map($result, dataset("GoogleFeedFetcher")); | 
| 39 | 6 |  |  |  |  | 25 | return 1; | 
| 40 |  |  |  |  |  |  | } | 
| 41 | 30 | 100 |  |  |  | 113 | if (index($ua, "AppEngine-Google") > -1) { | 
| 42 | 6 |  |  |  |  | 26 | update_map($result, dataset('GoogleAppEngine')); | 
| 43 | 6 |  |  |  |  | 22 | return 1; | 
| 44 |  |  |  |  |  |  | } | 
| 45 | 24 | 100 |  |  |  | 84 | if (index($ua, "Google Web Preview") > -1) { | 
| 46 | 6 |  |  |  |  | 22 | update_map($result, dataset('GoogleWebPreview')); | 
| 47 | 6 |  |  |  |  | 24 | return 1; | 
| 48 |  |  |  |  |  |  | } | 
| 49 |  |  |  |  |  |  |  | 
| 50 | 18 |  |  |  |  | 59 | return 0; | 
| 51 |  |  |  |  |  |  | } | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | sub challenge_crawlers { | 
| 54 | 1416 |  |  | 1416 | 0 | 2554 | my ($ua,$result) = @_; | 
| 55 |  |  |  |  |  |  |  | 
| 56 | 1416 | 100 | 100 |  |  | 37889 | if (index($ua, "Yahoo") > -1 || | 
|  |  | 100 | 100 |  |  |  |  | 
|  |  | 100 | 100 |  |  |  |  | 
|  |  | 100 | 100 |  |  |  |  | 
|  |  | 100 | 100 |  |  |  |  | 
|  |  | 100 |  |  |  |  |  | 
|  |  | 100 |  |  |  |  |  | 
|  |  | 100 |  |  |  |  |  | 
|  |  | 100 |  |  |  |  |  | 
|  |  | 100 |  |  |  |  |  | 
|  |  | 100 |  |  |  |  |  | 
|  |  | 100 |  |  |  |  |  | 
|  |  | 100 |  |  |  |  |  | 
|  |  | 100 |  |  |  |  |  | 
|  |  | 100 |  |  |  |  |  | 
|  |  | 100 |  |  |  |  |  | 
|  |  | 100 |  |  |  |  |  | 
|  |  | 100 |  |  |  |  |  | 
|  |  | 100 |  |  |  |  |  | 
|  |  | 100 |  |  |  |  |  | 
|  |  | 100 |  |  |  |  |  | 
|  |  | 100 |  |  |  |  |  | 
| 57 |  |  |  |  |  |  | index($ua, "help.yahoo.co.jp/help/jp/") > -1 || | 
| 58 |  |  |  |  |  |  | index($ua, "listing.yahoo.co.jp/support/faq/") > -1) { | 
| 59 | 66 | 100 | 100 |  |  | 654 | if (index($ua, "compatible; Yahoo! Slurp") > -1) { | 
|  |  | 100 | 100 |  |  |  |  | 
|  |  | 100 | 100 |  |  |  |  | 
|  |  | 100 |  |  |  |  |  | 
|  |  | 100 |  |  |  |  |  | 
| 60 | 12 |  |  |  |  | 44 | update_map($result, dataset("YahooSlurp")); | 
| 61 | 12 |  |  |  |  | 50 | return 1; | 
| 62 |  |  |  |  |  |  | } | 
| 63 |  |  |  |  |  |  | elsif (index($ua, "YahooFeedSeekerJp") > -1 || index($ua, "YahooFeedSeekerBetaJp") > -1) { | 
| 64 | 12 |  |  |  |  | 41 | update_map($result, dataset("YahooJP")); | 
| 65 | 12 |  |  |  |  | 40 | return 1; | 
| 66 |  |  |  |  |  |  | } | 
| 67 |  |  |  |  |  |  | elsif (index($ua, "crawler (http://listing.yahoo.co.jp/support/faq/") > -1 || | 
| 68 |  |  |  |  |  |  | index($ua, "crawler (http://help.yahoo.co.jp/help/jp/") > -1 ) { | 
| 69 | 18 |  |  |  |  | 78 | update_map($result, dataset("YahooJP")); | 
| 70 | 18 |  |  |  |  | 66 | return 1; | 
| 71 |  |  |  |  |  |  | } | 
| 72 |  |  |  |  |  |  | elsif (index($ua, 'Y!J-BRZ/YATSHA crawler') > -1 || index($ua, 'Y!J-BRY/YATSH crawler') > -1) { | 
| 73 | 12 |  |  |  |  | 40 | update_map($result, dataset('YahooJP')); | 
| 74 | 12 |  |  |  |  | 46 | return 1; | 
| 75 |  |  |  |  |  |  | } | 
| 76 |  |  |  |  |  |  | elsif (index($ua, "Yahoo Pipes") > -1) { | 
| 77 | 6 |  |  |  |  | 23 | update_map($result, dataset("YahooPipes")); | 
| 78 | 6 |  |  |  |  | 20 | return 1; | 
| 79 |  |  |  |  |  |  | } | 
| 80 |  |  |  |  |  |  | } | 
| 81 |  |  |  |  |  |  | elsif (index($ua, "msnbot") > -1) { | 
| 82 | 30 |  |  |  |  | 86 | update_map($result, dataset("msnbot")); | 
| 83 | 30 |  |  |  |  | 91 | return 1; | 
| 84 |  |  |  |  |  |  | } | 
| 85 |  |  |  |  |  |  | elsif (index($ua, "bingbot") > -1) { | 
| 86 | 6 | 50 |  |  |  | 34 | if (index($ua, "compatible; bingbot") > -1) { | 
| 87 | 6 |  |  |  |  | 22 | update_map($result, dataset("bingbot")); | 
| 88 | 6 |  |  |  |  | 23 | return 1; | 
| 89 |  |  |  |  |  |  | } | 
| 90 |  |  |  |  |  |  | } | 
| 91 |  |  |  |  |  |  | elsif (index($ua, "BingPreview") > -1) { | 
| 92 | 6 |  |  |  |  | 25 | update_map($result, dataset("BingPreview")); | 
| 93 | 6 |  |  |  |  | 24 | return 1; | 
| 94 |  |  |  |  |  |  | } | 
| 95 |  |  |  |  |  |  | elsif (index($ua, "Baidu") > -1) { | 
| 96 | 18 | 50 | 100 |  |  | 114 | if (index($ua, "compatible; Baiduspider") > -1 || index($ua, "Baiduspider+") > -1 || index($ua, "Baiduspider-image+") > -1) { | 
|  |  |  | 66 |  |  |  |  | 
| 97 | 18 |  |  |  |  | 55 | update_map($result, dataset("Baiduspider")); | 
| 98 | 18 |  |  |  |  | 59 | return 1; | 
| 99 |  |  |  |  |  |  | } | 
| 100 |  |  |  |  |  |  | } | 
| 101 |  |  |  |  |  |  | elsif (index($ua, "Yeti") > -1) { | 
| 102 | 18 | 50 | 100 |  |  | 135 | if (index($ua, "http://help.naver.com/robots") > -1 || | 
|  |  |  | 66 |  |  |  |  | 
| 103 |  |  |  |  |  |  | index($ua, "http://help.naver.com/support/robots.html") > -1 || | 
| 104 |  |  |  |  |  |  | index($ua, "http://naver.me/bot") > -1) { | 
| 105 |  |  |  |  |  |  |  | 
| 106 | 18 |  |  |  |  | 58 | update_map($result, dataset("Yeti")); | 
| 107 | 18 |  |  |  |  | 62 | return 1; | 
| 108 |  |  |  |  |  |  | } | 
| 109 |  |  |  |  |  |  | } | 
| 110 |  |  |  |  |  |  | elsif (index($ua, "FeedBurner/") > -1) { | 
| 111 | 6 |  |  |  |  | 27 | update_map($result, dataset("FeedBurner")); | 
| 112 | 6 |  |  |  |  | 26 | return 1; | 
| 113 |  |  |  |  |  |  | } | 
| 114 |  |  |  |  |  |  | elsif (index($ua, "facebookexternalhit") > -1) { | 
| 115 | 6 |  |  |  |  | 24 | update_map($result, dataset("facebook")); | 
| 116 | 6 |  |  |  |  | 21 | return 1; | 
| 117 |  |  |  |  |  |  | } | 
| 118 |  |  |  |  |  |  | elsif (index($ua, "Twitterbot/") > -1) { | 
| 119 | 6 |  |  |  |  | 24 | update_map($result, dataset("twitter")); | 
| 120 | 6 |  |  |  |  | 21 | return 1; | 
| 121 |  |  |  |  |  |  | } | 
| 122 |  |  |  |  |  |  | elsif (index($ua, "ichiro") > -1) { | 
| 123 | 12 | 50 | 66 |  |  | 86 | if (index($ua, "http://help.goo.ne.jp/door/crawler.html") > -1 || index($ua, "compatible; ichiro/mobile goo;") > -1) { | 
| 124 | 12 |  |  |  |  | 63 | update_map($result, dataset("goo")); | 
| 125 | 12 |  |  |  |  | 48 | return 1; | 
| 126 |  |  |  |  |  |  | } | 
| 127 |  |  |  |  |  |  | } | 
| 128 |  |  |  |  |  |  | elsif (index($ua, "gooblogsearch/") > -1) { | 
| 129 | 6 |  |  |  |  | 24 | update_map($result, dataset("goo")); | 
| 130 | 6 |  |  |  |  | 23 | return 1; | 
| 131 |  |  |  |  |  |  | } | 
| 132 |  |  |  |  |  |  | elsif (index($ua, "Apple-PubSub") > -1) { | 
| 133 | 6 |  |  |  |  | 21 | update_map($result, dataset("ApplePubSub")); | 
| 134 | 6 |  |  |  |  | 21 | return 1; | 
| 135 |  |  |  |  |  |  | } | 
| 136 |  |  |  |  |  |  | elsif (index($ua, "(www.radian6.com/crawler)") > -1) { | 
| 137 | 12 |  |  |  |  | 38 | update_map($result, dataset("radian6")); | 
| 138 | 12 |  |  |  |  | 47 | return 1; | 
| 139 |  |  |  |  |  |  | } | 
| 140 |  |  |  |  |  |  | elsif (index($ua, "Genieo/") > -1) { | 
| 141 | 6 |  |  |  |  | 25 | update_map($result, dataset("Genieo")); | 
| 142 | 6 |  |  |  |  | 23 | return 1; | 
| 143 |  |  |  |  |  |  | } | 
| 144 |  |  |  |  |  |  | elsif (index($ua, "labs.topsy.com/butterfly/") > -1) { | 
| 145 | 6 |  |  |  |  | 25 | update_map($result, dataset("topsyButterfly")); | 
| 146 | 6 |  |  |  |  | 24 | return 1; | 
| 147 |  |  |  |  |  |  | } | 
| 148 |  |  |  |  |  |  | elsif (index($ua, "rogerbot/1.0 (http://www.seomoz.org/dp/rogerbot") > -1) { | 
| 149 | 12 |  |  |  |  | 42 | update_map($result, dataset("rogerbot")); | 
| 150 | 12 |  |  |  |  | 37 | return 1; | 
| 151 |  |  |  |  |  |  | } | 
| 152 |  |  |  |  |  |  | elsif (index($ua, "compatible; AhrefsBot/") > -1) { | 
| 153 | 6 |  |  |  |  | 22 | update_map($result, dataset("AhrefsBot")); | 
| 154 | 6 |  |  |  |  | 20 | return 1; | 
| 155 |  |  |  |  |  |  | } | 
| 156 |  |  |  |  |  |  | elsif (index($ua, "livedoor FeedFetcher") > -1 || index($ua, "Fastladder FeedFetcher") > -1) { | 
| 157 | 12 |  |  |  |  | 47 | update_map($result, dataset("livedoorFeedFetcher")); | 
| 158 | 12 |  |  |  |  | 35 | return 1; | 
| 159 |  |  |  |  |  |  | } | 
| 160 |  |  |  |  |  |  | elsif (index($ua, "Hatena ") > -1) { | 
| 161 | 18 | 50 | 100 |  |  | 126 | if (index($ua, "Hatena Antenna") > -1 || index($ua, "Hatena Pagetitle Agent") > -1 || index($ua, "Hatena Diary RSS") > -1) { | 
|  |  |  | 66 |  |  |  |  | 
| 162 | 18 |  |  |  |  | 57 | update_map($result, dataset("Hatena")); | 
| 163 | 18 |  |  |  |  | 55 | return 1; | 
| 164 |  |  |  |  |  |  | } | 
| 165 |  |  |  |  |  |  | } | 
| 166 |  |  |  |  |  |  | elsif (index($ua, "mixi-check") > -1 || index($ua, "mixi-crawler") > -1 || index($ua, "mixi-news-crawler") > -1) { | 
| 167 | 18 |  |  |  |  | 66 | update_map($result, dataset("mixi")); | 
| 168 | 18 |  |  |  |  | 59 | return 1; | 
| 169 |  |  |  |  |  |  | } | 
| 170 |  |  |  |  |  |  | elsif (index($ua, "Indy Library") > -1) { | 
| 171 | 6 | 50 |  |  |  | 44 | if (index($ua, "compatible; Indy Library") > -1) { | 
| 172 | 6 |  |  |  |  | 24 | update_map($result, dataset("IndyLibrary")); | 
| 173 | 6 |  |  |  |  | 29 | return 1; | 
| 174 |  |  |  |  |  |  | } | 
| 175 |  |  |  |  |  |  | } | 
| 176 |  |  |  |  |  |  | elsif (index($ua, "trendictionbot") > -1) { | 
| 177 | 6 |  |  |  |  | 35 | update_map($result, dataset("trendictionbot")); | 
| 178 | 6 |  |  |  |  | 24 | return 1; | 
| 179 |  |  |  |  |  |  | } | 
| 180 |  |  |  |  |  |  |  | 
| 181 | 1134 |  |  |  |  | 3150 | return 0; | 
| 182 |  |  |  |  |  |  |  | 
| 183 |  |  |  |  |  |  | } | 
| 184 |  |  |  |  |  |  |  | 
| 185 |  |  |  |  |  |  | sub challenge_maybe_crawler { | 
| 186 | 69 |  |  | 69 | 0 | 133 | my ($ua, $result) = @_; | 
| 187 |  |  |  |  |  |  |  | 
| 188 | 69 | 100 |  |  |  | 483 | if ($ua =~ m{(bot|crawler|spider)(?:[-_ ./;@()]|$)}oi) { | 
| 189 | 48 |  |  |  |  | 140 | update_map($result, dataset("VariousCrawler")); | 
| 190 | 48 |  |  |  |  | 157 | return 1; | 
| 191 |  |  |  |  |  |  | } | 
| 192 | 21 | 100 | 66 |  |  | 117 | if ($ua =~ m{^(?:Rome Client |UnwindFetchor/|ia_archiver |Summify |PostRank/)}o | 
| 193 |  |  |  |  |  |  | or index($ua, "ASP-Ranker Feed Crawler") > -1) { | 
| 194 | 12 |  |  |  |  | 35 | update_map($result, dataset("VariousCrawler")); | 
| 195 | 12 |  |  |  |  | 43 | return 1; | 
| 196 |  |  |  |  |  |  | } | 
| 197 | 9 | 100 |  |  |  | 63 | if ($ua =~ m{(feed|web) ?parser}oi) { | 
| 198 | 6 |  |  |  |  | 23 | update_map($result, dataset("VariousCrawler")); | 
| 199 | 6 |  |  |  |  | 21 | return 1; | 
| 200 |  |  |  |  |  |  | } | 
| 201 | 3 | 50 |  |  |  | 21 | if ($ua =~ m{watch ?dog}oi) { | 
| 202 | 3 |  |  |  |  | 12 | update_map($result, dataset("VariousCrawler")); | 
| 203 | 3 |  |  |  |  | 11 | return 1; | 
| 204 |  |  |  |  |  |  | } | 
| 205 |  |  |  |  |  |  |  | 
| 206 | 0 |  |  |  |  |  | return 0; | 
| 207 |  |  |  |  |  |  | } | 
| 208 |  |  |  |  |  |  |  | 
| 209 |  |  |  |  |  |  | 1; | 
| 210 |  |  |  |  |  |  |  | 
| 211 |  |  |  |  |  |  | __END__ |