代码: 全选
● cat paste-img.pl
#!/usr/bin/perl -w
use utf8;
use strict;
use WWW::Mechanize;
use Net::DBus;
my $bus = Net::DBus->session->get_service('org.freedesktop.Notifications')
->get_object('/org/freedesktop/Notifications','org.freedesktop.Notifications');
my $mech = WWW::Mechanize->new();
my $web_select="imagebin"; #选择贴图网站的缩写短语,会在列表中自动匹配的。
my $add;
#======================
my %web=( "http://www.cjb.net/"=>{"image"=>$ARGV[0]},
"http://kimag.es/"=>{"userfile1"=>$ARGV[0]},
"http://imagebin.org/index.php?page=add"=>{"nickname"=>"eexp","image" => $ARGV[0],"disclaimer_agree"=>"Y"},
"http://paste.ubuntu.org.cn/"=>{"poster"=>"eexp","screenshot"=>$ARGV[0],"code2"=>join("\n",`xsel -o`)},
);
foreach (keys %web){$add=$_,last if /$web_select/;}
if(!$add){$bus->Notify("paste-img", 0, "error", '无效网站地址', ':(', [], { }, -1);exit;}
print $web_select."\n";
#======================
$mech -> get($add);
$mech -> submit_form(with_fields => $web{$add});
#======================
if ($mech->success()) {
my $rr=$mech->uri();
print "贴图地址: $rr 。\n";
`echo $rr|xsel -i`;
$bus->Notify("paste-img", 0, "sunny", '贴图地址', $rr, [], { }, -1);
} else {
$bus->Notify("paste-img", 0, "error", '贴图失败', ':(', [], { }, -1);
print "ERROR:\t".$mech->status()."\n";
}
#======================
代码: 全选
● cat paste-img.pl
#!/usr/bin/perl -w
use utf8;
use strict;
use WWW::Mechanize;
use Net::DBus;
my $mech = WWW::Mechanize->new();
my $web_select="cjb";
#my $web_select="kimag";
#my $web_select="ubuntu";
#======================
#----cjb----
if($web_select eq "cjb"){
$mech -> get("http://www.cjb.net/");
$mech -> submit_form(
with_fields => {"image" => $ARGV[0]});
}
#http://www.cjb.net/images.html?d2bbe.jpg
#http://images.cjb.net/d2bbe.jpg
#======================
#----kimag----
if($web_select eq "kimag"){
$mech -> get("http://kimag.es/");
$mech -> submit_form(
with_fields => {"userfile1" => $ARGV[0]});
# form_number => 1,
# fields => {"userfile1" => $ARGV[0]});
}
#http://kimag.es/view.php?i=55323637.jpg
#http://kimag.es/share/55323637.jpg
#======================
#----paste.ubuntu----
if($web_select eq "ubuntu"){
$mech -> get("http://paste.ubuntu.org.cn/");
$mech -> submit_form(
form_name => "editor" ,
fields => {
"screenshot" => $ARGV[0],
"code2" => join("\n",`xsel -o`),
"poster" => "eexp"
} ,
button => "paste");
}
#======================
my $bus = Net::DBus->session->get_service('org.freedesktop.Notifications')
->get_object('/org/freedesktop/Notifications','org.freedesktop.Notifications');
if ($mech->success()) {
my $rr=$mech->uri();
print "贴图地址: $rr 。\n";
`echo $rr|xsel -i`;
$bus->Notify("paste-img", 0, "sunny", '贴图地址', $rr, [], { }, -1);
} else {
$bus->Notify("paste-img", 0, "error", '贴图失败', ':(', [], { }, -1);
print "ERROR:\t".$mech->status()."\n";
}
#======================