2 use 5.010; use strict; use warnings;
6 if (m{<td class=hl>} .. m{</?td>}) {
7 $count{-source} = 'http://stats.wikimedia.org/archive/squid_reports/';
8 $count{-title } = 'Wikimedia';
9 $count{-date} = $1 if m{ period: (?:\d+ )?(\w+ \d+) };
13 # select relevant columns
14 />Browser versions(.*)/ ... m{</table>} && last or next;
15 my ($tr, $id, $count2, $count) = split /(?:<[^>]*>)+/;
16 $mobile = $count2 =~ /(?<!non) mobile/ if $id ~~ ' ';
17 next if $id ~~ ['Total', ' '];
19 # convert to usable syntax
20 my ($browser, $version) = split /\h+/, $id, 2;
25 when (['Firefox', 'Iceweasel']) {
34 $browser = $mobile ? 'op_mob' : 'opera';
36 if (m{\(Mini(.*)\)$}) {
38 ($_) = $1 =~ m{^/(\d+)};
41 s/^\d*\.\d\K.*//; # one significant digit
46 $browser = $mobile ? 'ios_saf' : 'safari';
47 my $numversion = join('.', map { sprintf '%03d', $_ } split /\./, $version);
48 $numversion =~ s/6(?=\d{3})//; # incomparable 6532.22 → 523
50 # http://en.wikipedia.org/wiki/Safari_version_history
63 [ '525.013' => '3.1' ],
64 [ '525.026' => '3.2' ],
70 last if $numversion lt $_->[0];
76 s/\.\d+$// for $version;
81 s/\.0$// for $version;
84 $count{$browser}{$version} += $count;
95 curl http://stats.wikimedia.org/archive/squid_reports/2010-10/SquidReportClients.htm |
96 parsesquid.pl > browser-usage.inc.pl