标题: [原创教程] [示例][LWP::UserAgent]Perl登录论坛并下载个人信息 [打印本页]
作者: 523066680 时间: 2014-8-8 20:42 标题: [示例][LWP::UserAgent]Perl登录论坛并下载个人信息
- #!/usr/bin/perl
- use strict;
- use LWP::UserAgent;
-
- my $ua = LWP::UserAgent->new;
- $ua->cookie_jar( {} );
- my $res= $ua->post('http://bbs.bathome.net/logging.php?action=login',
- [
- loginsubmit=>"yes",
- floatlogin=>"yes",
- loginfield=>"username",
- username=>"账号",
- password=>"密码",
- questionid=>N,
- answer=>"提问答案",
- cookietime=>"2592000",
- ],
- );
-
- $res = $ua->get('http://bbs.bathome.net/memcp.php');
-
- open(FILE, '>bathome.html');
- print FILE $res->content;
- close FILE;
复制代码
post里面的信息每个网站不尽相同,可以手动登录,使用火狐live http headers插件获取POST信息,
然后依样画葫芦,修改代码即可。
登录BATHOME之前打开live http headers插件,登陆后获取POST信息大致如下(适当做了替换)
#POST /logging.php?action=login&loginsubmit=yes&floatlogin=yes&inajax=1
# formhash=161fb4b8&referer=http%3A%2F%2Fbbs.bathome.net%2Fthread-30857-1-1.html
# &loginfield=username
# &username=523066680
# &password=***人为屏蔽***
# &questionid=提问问题的编号
# &answer="答案"
# &cookietime=2592000
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |