Last active
August 29, 2015 14:19
-
-
Save CLCL/f3519894d6a8a3d1f52a to your computer and use it in GitHub Desktop.
PukiWikiの特定ページに鬼の様な大量のSPAM添付ファイルがぶっこまれた時、PerlのヘッドレスブラウザモジュールのWWW::Mechanizeを使って消します。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use utf8; | |
use WWW::Mechanize; | |
# deldel.pl PukiWikiのページ内添付ファイルを根こそぎ消す | |
my $pageurl = 'http://dtpwiki.jp/index.php?Perl'; | |
my $password = 'naishodayo'; | |
my $mech = WWW::Mechanize->new; | |
$mech->agent_alias('Mac Safari'); | |
$mech->get($pageurl); | |
my @links = $mech->find_all_links( tag => "a", text_regex => qr/詳細/i ); | |
foreach my $link ( @links ) { | |
my $url = $link->url(); | |
next if $url =~ m/kannren2.gif/; | |
next if $url =~ m/kannren1.gif/; | |
next if $url =~ m/E8%89%B2%E6%B7%B7_ver2.txt/; | |
print "$url\n"; | |
go_shousai( $link ); | |
#sleep 1; | |
} | |
sub go_shousai { | |
my $link = shift; | |
$mech->get( $link ); | |
# die $mech->content(); | |
$mech->field("pcmd", "delete"); | |
$mech->submit_form( | |
fields => { | |
pass => $password, | |
}, | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
requires 'WWW::Mechanize'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment