-
Notifications
You must be signed in to change notification settings - Fork 0
/
srrup.pl
51 lines (38 loc) · 931 Bytes
/
srrup.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/perl
use strict;
use warnings;
use v5.10;
use WWW::Mechanize;
use HTTP::Request::Common;
use HTML::TreeBuilder::XPath;
my $username = '';
my $password = '';
if (@ARGV < 1) {
say STDERR "Usage: $0 file.srr [file.srr...]";
exit 1;
}
my @files = @ARGV;
my $mech = WWW::Mechanize->new;
$mech->post('http://www.srrdb.com/account/login', {
username => $username,
password => $password,
});
foreach (@files) {
upload_srr($_);
};
sub upload_srr {
my $file = shift;
my $req = $mech->request(POST 'http://www.srrdb.com/upload',
Content_Type => 'form-data',
Content => {
file => [ $file ],
upload => 'upload',
});
my $tree = HTML::TreeBuilder::XPath->new_from_content($req->decoded_content)->elementify;
my $error = $tree->findvalue('//span[@class="error"]');
if ($error) {
say STDERR $error;
exit 1;
}
say $tree->findvalue('//div[@class="oflow wName"');
}