comparison Ikariam.pm @ 7:2040ccc95670

implemented scores collection.
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Wed, 08 Oct 2008 02:50:19 +0800
parents 2975a94aa7a2
children e4b3168d0319
comparison
equal deleted inserted replaced
6:2975a94aa7a2 7:2040ccc95670
1 #!/usr/bin/env perl 1 #!/usr/bin/env perl
2 2
3 use Class::DBI::AutoLoader ( 3 use Class::DBI::AutoLoader (
4 dsn => 'dbi:SQLite:dbname=ikariam.sqlite', 4 dsn => 'dbi:SQLite:dbname=ikariam.sqlite',
5 options => { RaiseError => 1 }, 5 options => { RaiseError => 1 },
6 tables => ['cities', 'islands', 'users'], 6 tables => ['cities', 'island', 'users'],
7 use_base => 'Class::DBI::SQLite', 7 use_base => 'Class::DBI::SQLite',
8 namespace => 'Ikariam', 8 namespace => 'Ikariam',
9 ); 9 );
10 10
11 package Ikariam; 11 package Ikariam;
12 12
13 use Data::Dumper; 13 use Data::Dumper;
14 use LWP; 14 use LWP;
15 # use LWP::Debug qw(+ -conns); 15 # use LWP::Debug qw(+ -conns -trace -debug);
16 use LWP::Debug qw(+trace);
16 use HTTP::Cookies; 17 use HTTP::Cookies;
17 use WWW::Mechanize; 18 use WWW::Mechanize;
18 use HTML::TagParser; 19 use HTML::TagParser;
19 use IO::Uncompress::Gunzip qw(gunzip $GunzipError) ; 20 use IO::Uncompress::Gunzip qw(gunzip $GunzipError) ;
20 21
41 my $self = shift; 42 my $self = shift;
42 my $type = shift || 'score'; 43 my $type = shift || 'score';
43 my $user = shift || ''; 44 my $user = shift || '';
44 my $offset = shift || 0; 45 my $offset = shift || 0;
45 46
46 my $res = $self->{mech}->post(sprintf("http://%s/index.php?view=worldmap_iso", $self->{server}), [ 47 my $res = $self->{mech}->post(sprintf("http://%s/index.php", $self->{server}), [
47 highscoreType => $type, 48 highscoreType => $type,
48 offset => $offset, 49 offset => $offset,
49 searchUser => $user, 50 searchUser => $user,
50 view => 'highscore' 51 view => 'highscore'
51 ]); 52 ]);