-
-
Save dalinaum/772133 to your computer and use it in GitHub Desktop.
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/env perl | |
use utf8; | |
use strict; | |
use warnings; | |
use WWW::Mechanize; | |
binmode STDOUT, ':encoding(UTF-8)'; | |
use constant { | |
PROGRAMMING_GALLERY => 'http://gall.dcinside.com/list.php?id=programming', | |
LOGIN => 'http://www.dcinside.com/', | |
NUMBER_OF_NOTICE => 3 | |
}; | |
my $browser = WWW::Mechanize->new(); | |
$browser->get(LOGIN); | |
$browser->submit_form( | |
form_name => 'login', | |
fields => { | |
user_id => '#####', | |
password => '######' | |
}); | |
$browser->get(PROGRAMMING_GALLERY); | |
my $list = $browser->content; | |
my @links = $browser->find_all_links(url_regex => qr[&no=\d*.*bbs]); | |
foreach (1 .. NUMBER_OF_NOTICE) { | |
shift @links; | |
} | |
foreach my $link (@links) { | |
my $uri = $link->url_abs; | |
print "$uri\n"; | |
$browser->get($uri); | |
my $article = $browser->content; | |
my ($nickname) = $article =~ m/user_name=(.*)\"/g; | |
my $comment = "[테스트] ${nickname}님 반갑습니다."; | |
print "$comment\n"; | |
$browser->submit_form( | |
form_name => 'write_com', | |
fields => { | |
memo => $comment | |
}); | |
sleep 1; | |
} | |
# Requrirement: | |
# - install modules (IO::Socket::SSL, WWW::Mechanize). | |
# - install p5-crypt-ssleay (if you use a mac). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment