具体程序如下
readcokie.pl
======================
# -*- coding: gb2312 -*-
#$ua->post( $url, \%form )
#$ua->post( $url, \@form )
#$ua->post( $url, \%form, $field_name => $value, ... )
#This method will dispatch a POST request on the given $url, with %form or @form providing the key/value pairs for the fill-in form content. Additional headers and content options are the same as for the get() method.
#This method will use the POST() function from HTTP::Request::Common to build the request. See the HTTP::Request::Common manpage for a details on how to pass form content and other advanced features.
#$ua->get( $url )
#$ua->get( $url , $field_name => $value, ... )
#This method will dispatch a GET request on the given $url. Further arguments can be given to initialize the headers of the request. These are given as separate name/value pairs. The return value is a response object. See the HTTP::Response manpage for a description of the interface it provides.
#$ua->agent('Mozilla/5.0');
use HTTP::Cookies;
use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
$ua = LWP::UserAgent->new;
open(FILE,'D:\bin\posttools\自动发帖\bt区顶贴\cc8.cnsuk.net新沙加神话\data\user.txt');
@file=<FILE>;
for ($i=0;$i<=$#file;$i++){
chomp($file[$i]);
($user,$pass)=split(/,/,$file[$i]);
$ua->cookie_jar(HTTP::Cookies->new(file => "D:\\bin\\posttools\\自动发帖\\bt区顶贴\\cc8.cnsuk.net新沙加神话\\data\\$user\\cookie.txt",
autosave => 1));
$req =POST 'http://www1.5hxy.com/bbs/login.asp',
[UserName => $user,
Userpass => $pass,
IsSave => '1',
Eremite => '1',
];
$res=$ua->request($req);
$ua->cookie_jar->save;
# $ua = LWP::UserAgent->close;
}
fatie.pl
=============================
use HTTP::Cookies;
use LWP;
$ua = LWP::UserAgent->new;
$ua->agent("Mozilla/8.0"
#初始化参数
$n_file='D:\bin\posttools\自动发帖\bt区顶贴\cc8.cnsuk.net新沙加神话\\';