免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2264 | 回复: 2
打印 上一主题 下一主题

用perl在discuz发帖子有什么需要注意点的地方么? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-12-25 15:28 |只看该作者 |倒序浏览
用抓包工具看到post的时候有个formhash,这个已经在发帖前在网页源代码里面提取到了。
问题是post过去后我发的帖子并没有出现?
并且 $response->status_line; 返回状态是200

[ 本帖最后由 yz86yz 于 2009-12-25 15:31 编辑 ]

论坛徽章:
0
2 [报告]
发表于 2009-12-25 15:33 |只看该作者
#!/usr/bin/perl

use strict;
use warnings;

print "Hello, World...n";
use LWP::UserAgent;
use HTTP::Cookies;
my %ua_option = (
agent => "Mozilla/4.0",
timeout => 180,
);

my $ua = LWP::UserAgent->new(%ua_option);
push @{$ua->requests_redirectable() }, 'POST';
$ua -> cookie_jar( HTTP::Cookies->new(
    'file' => 'cookies.lwp',
        # where to read/write cookies

    'autosave' => 1,
        # save it to disk when done

  ));

my $myurl="http://bbs.88888.com/index.php";
my $formhash="";
my $formhash_1="";
my $cookietime="";
my $res = $ua->get ($myurl);
my @login_page = split (/\n/,$res->content);
foreach (@login_page) {
        if (/formhash" w+="(w+)"/){
                  $formhash = $1;

        if (/cookietime"
w+="(w+)"/)           {
                  $cookietime = $1;
                      }
my $response = $ua ->post ($myurl,[
'cookietime' =>$cookietime,
'formhash' =>$formhash,
'loginfield' =>'username',
'password'=>'88888',
'username' =>'8888',
]);
die "url error: ", $response->status_line
   unless $response->is_success;

  my $url_1="http://bbs.8888.com/thread-1428131-21-1.html";
  $res = $ua->get ($url_1);
  my @post_page = split (/\n/,$res->content);
  foreach (@post_page) {
        if (/formhash=([wd]{8})/){
                  $formhash_1 = $1;
                  print "Find hash1: $formhash_1 n";}
                       }
  $response = $ua ->post ($url_1,[
'formhash' =>$formhash_1,
'message' =>'恭喜发财啊 哈哈哈哈',
'subject' =>'1t1t',
   ]);
if ($response ->is_success) {
    my $content_1=$response->status_line;
    print "$content_1 n";
}


[ 本帖最后由 yz86yz 于 2009-12-25 15:37 编辑 ]

论坛徽章:
0
3 [报告]
发表于 2009-12-26 13:34 |只看该作者
用telnet发过SMTH BBS的帖子 这个倒是没用过,不过用lwp肯定得行
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP