Skip to content

Instantly share code, notes, and snippets.

@dalinaum
Forked from iceandguard/gist:765150
Created January 9, 2011 23:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dalinaum/772133 to your computer and use it in GitHub Desktop.
Save dalinaum/772133 to your computer and use it in GitHub Desktop.
#!/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