|
楼主 |
发表于 2011-12-14 22:17:37
|
显示全部楼层
[code][/code]
#!perl
use warnings;
use strict;
use Data:umper;
use Win32::OLE qw( EVENTS );
my $time;
my $ie;
my $j = 0;
my $retry = 0;
my $url;
my @url;
$url[0]='http://bbs.eetop.cn/thread-252321-1-2.html?tid=252321&extra=page%3D2&page=1';
$url[1]='http://bbs.eetop.cn/thread-21237-1-1.html';
$url[2]='http://bbs.eetop.cn/thread-184738-1-1.html';
$url[3]='http://bbs.eetop.cn/thread-166743-1-1.html';
$url[4]='http://bbs.eetop.cn/thread-257214-1-1.html';
$url[5]='http://bbs.eetop.cn/thread-257342-1-1.html';
$url[6]='http://bbs.eetop.cn/thread-174228-1-2.html';
$url[7]='http://bbs.eetop.cn/thread-229120-1-1.html';
$url[8]='http://bbs.eetop.cn/thread-185924-1-1.html';
$url[9]='http://bbs.eetop.cn/thread-245737-1-2.html';
$url[10]='http://bbs.eetop.cn/thread-215741-1-1.html';
$url[11]='http://bbs.eetop.cn/thread-149597-1-1.html';
$url[12]='http://bbs.eetop.cn/thread-208954-1-1.html';
$url[13]='http://bbs.eetop.cn/thread-186966-1-1.html';
$url[14]='http://bbs.eetop.cn/thread-245737-1-1.html';
my @msg;
$msg[0]='我要信元,我要信元';
$msg[1]='灌灌更健康';
$msg[2]='一直灌~一直灌';
$msg[3]='为了10000不停灌!';
$msg[4]='哥为下载而来,灌水是我的风采。';
$msg[5]='大家赚才是真的赚,大家一起灌';
$msg[6]='先顶后看,养成习惯!!!!!';
$msg[7]='对不起,您两次发表间隔少于 60 秒,请不要灌水!';
$msg[8]='为了书夜以继日地灌水';
$msg[9]='灌水救中國';
$msg[10]='灌了个灌';
$msg[11]='灌的越多 赚的越多';
Win32::OLE->Initialize(Win32::OLE::COINIT_OLEINITIALIZE);
for (0..2000) {
open LOG,'>>D:\private\skill\guanshui.txt' or die $!;
$ie = Win32::OLE->new( 'InternetExplorer.Application' ) or die "error starting IE";
#$ie = Win32::OLE->GetActiveObject('InternetExplorer.Application') || Win32::OLE->new('InternetExplorer.Application', 'Quit') or die "error starting IE";
$ie->{visible} = 0;
Win32::OLE->WithEvents( $ie, \&Event, 'DWebBrowserEvents2' );
Win32::OLE->Option( Warn => 3 );
$url = $url[int rand(@url)];
$j ++;
print LOG "==> $url\n";
$ie->navigate($url);
Win32::OLE->MessageLoop();
$ie->Quit() if (defined $ie);
undef $ie;
close LOG;
sleep 60;
}
sub Event
{
my ($obj,$Event,@Args) = @_;
my $IEObject = shift @Args;
if ($Event eq 'DocumentComplete') {
my $Doc = $IEObject->{Document};
if ( $Doc->{URL} eq $url ) {
my $elem= $Doc->getElementById('fastpostmessage');
my $form = $Doc->getElementById('fastpostform');
if (! defined $form){
$retry ++;
if ($retry == 100) {
print LOG "ERROR: Already tried 10 times\n";
close LOG;
Win32::OLE->QuitMessageLoop();
# $ie->Quit() if (defined $ie);
# undef $ie;
die;
}
else{
print LOG "ERROR: Retry for the $retry time!\n";
close LOG;
Win32::OLE->QuitMessageLoop();
$ie->Quit() if (defined $ie);
undef $ie;
sleep 65;
next;
}
}
$time = localtime();
$elem->{value} = $msg[int rand(@msg)];
$form->submit();
print LOG "$j\t灌水成功 @ $time\n";
Win32::OLE->QuitMessageLoop();
}
}
if ($Event eq "OnQuit"){
Win32::OLE->QuitMessageLoop();
print LOG "$j\tERROR: \$Event eq OnQuit happened!\n";
}
} |
|