Created
January 4, 2011 18:15
-
-
Save iceandguard/765150 to your computer and use it in GitHub Desktop.
Hello, Programming Gallery.
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 | |
# $Revision$ | |
# $Source$ | |
# $Id$ | |
# $HeadURL$ | |
# $Date$ | |
use utf8; | |
use Carp; | |
use 5.010; | |
use strict; | |
use warnings; | |
use ReadOnly; | |
use WWW::Mechanize; | |
our $VERSION = '1.0'; | |
binmode STDOUT, ':encoding(UTF-8)'; | |
Readonly::Scalar my $PROGRAMMING_GALLERY => | |
'http://gall.dcinside.com/list.php?id=programming'; | |
Readonly::Scalar my $LOGIN => 'http://www.dcinside.com/'; | |
Readonly::Scalar my $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/ ); | |
shift @links foreach ( 1 .. $NUMBER_OF_NOTICE ); | |
foreach my $link (@links) { | |
my $uri = $link->url_abs; | |
print "$uri\n" or croak('Coudn\'t print'); | |
$browser->get($uri); | |
my $article = $browser->content; | |
my ($nickname) = $article =~ /user_name=(.*?)\"/gm; | |
my $comment = "[테스트] ${nickname}님 반갑습니다."; | |
print "$comment\n" or croak('Coudn\'t print'); | |
$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