use strict; use warnings; use WWW::Mechanize::Firefox; # Requires MozRepl addon for Firefox use WWW::Mechanize; use Date::Manip; use DateTime; open TXT, "<", "nickname.log"; while(! eof (TXT)){ my $nick = ; chomp $nick; my $j = 0; for $j(0..3){ open MATCH, "+<", "match.log"; my (@gotmatch) = ; my ($date) = DateTime->now; my ($k) = 0; while($k < $j){ $date = $date->subtract( days => 7); $k++; } $date = $date->ymd; $url = "http://www.quakelive.com/#profile/matches/$nick/$date"; my ($firemech) = WWW::Mechanize::Firefox->new(); $firemech->get($url); die "Cannot connect to $url\n" if !$firemech->success(); my ($retries) = 10; while ($retries-- and ! $firemech->is_visible( xpath => '//*[@class="areaMapC"]' )) { sleep 1; } die "Timeout" unless $retries; my ($content) = $firemech->content(); while(($content =~ /class="areaMapC" id="([^<]+)_([^<]+)_([^<]+)">/gsi)){ my ($game) = $1; my ($longid) = $2; my ($shortid) = $3; my ($matchid) = "$longid/$game/$shortid\n"; # Checks match.log for duplicates my ($flag) = 0; for my $l(0..$#gotmatch){ if($matchid eq $gotmatch[$l]){ $flag = 1; } } if($flag == 0){ print MATCH $matchid; $flag = 0; } } close MATCH; undef $firemech; $j++; } }