Проверял с ФФ/geckodriver и selenium-server-standalone.
Поставить нужно
- selenium-server-standalone 3.12.0-1
- perl-selenium-remote-driver 1.28-1
- geckodriver 0.20.1-1
ну и файрфокс.
java -jar /usr/share/selenium-server/selenium-server-standalone.jar
#!/usr/bin/perl -w
#
# Dump sberbank card list and payments history
#
# Usage:
# $0 <login> <password>
#
use utf8;
use Selenium::Remote::Driver;
$login = shift @ARGV;
$password = shift @ARGV;
binmode(STDOUT, ":utf8");
binmode(STDERR, ":utf8");
print STDERR "Starting browser\n";
my $driver = Selenium::Remote::Driver->new_from_caps(
'desired_capabilities' => {
'browserName' => 'firefox',
'moz:firefoxOptions' => {
'args' => [ '--safe-mode', '--headless' ]
# 'args' => [ '--safe-mode' ]
}
});
print STDERR "Logging in\n";
$driver->get('https://online.sberbank.ru/CSAFront/index.do');
$driver->find_element_by_id('login')->send_keys($login);
$driver->find_element_by_id('password')->send_keys($password);
$driver->get('javascript:validateAndSubmit()');
print STDERR "Getting info";
my @products = ();
while(scalar @products == 0) {
@products=$driver->find_elements("//div[\@class='forProductBorder mainProductInfo']");
sleep(1);
print STDERR ".";
}
print STDERR "\n";
$driver->get('https://node1.online.sberbank.ru/PhizIC/private/cards/list.do');
print STDERR "Getting info";
@products = ();
while(scalar @products == 0) {
@products=$driver->find_elements("//div[\@class='productCover activeProduct ']");
sleep(1);
print STDERR ".";
}
print STDERR "\n";
my %products = ();
foreach $p (@products) {
$name_el=$driver->find_child_element($p, "./div//span[\@class='mainProductTitle mainProductTitleLight']");
$name=$name_el->get_text();
$open=$name_el->get_attribute('onclick', 1);
$amount=$driver->find_child_element($p, "./div//span[\@class='overallAmount nowrap']")->get_text();
$number=$driver->find_child_element($p, "./div//div[\@class='accountNumber decoration-none']")->get_text();
if($number =~ / (\d{4}),/) {
$n = "card#".$1;
} else {
$n = "rand#".int(rand(10000)); # TODO: fixme
}
$products{$n}{'number'} = $number;
$products{$n}{'amount'} = $amount;
$products{$n}{'open'} = $open;
$products{$n}{'name'} = $name;
print "$name = $amount\n\t$number\n\t$open\n";
}
print "\n\n";
foreach $p (keys %products) {
$open = $products{$p}{'open'};
$name = $products{$p}{'name'};
$driver->get("javascript:".$open);
print STDERR "Getting history for $p ($name)";
my @history = ();
while(scalar @history == 0) {
@history=$driver->find_elements("//table[\@class='tblInf']");
sleep(1);
print STDERR ".";
}
print STDERR "\n";
sleep(2); # TODO: fix this hack!
$history=$driver->find_element("//table[\@class='tblInf']");
@items=$driver->find_child_elements($history, "./tbody//tr[\@class='ListLine0'] | ./tbody//tr[\@class='ListLine1']");
foreach $i (@items) {
$name=$driver->find_child_element($i, "./td[\@class='align-left leftPaddingCell']")->get_text();
$date=$driver->find_child_element($i, "./td[\@class='listItem']")->get_text();
$amount=$driver->find_child_element($i, "./td[\@class='align-right']")->get_text();
print "\t$date, $amount, $name\n";
}
print "\n\n";
}
print STDERR "Quit\n";
$driver->quit();