免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: thevoice
打印 上一主题 下一主题

接下来该怎么办? [复制链接]

论坛徽章:
0
11 [报告]
发表于 2007-04-24 10:54 |只看该作者
IE的用于查看header插件很多, 但是都暴难用。(个人观点)
强烈推荐Firefox的livehttpheaders扩展。
如果是win下的, httpdetect这个sinffer最好用了。(而且很小很容易上手)

论坛徽章:
0
12 [报告]
发表于 2007-04-24 11:06 |只看该作者
鬼桥(achilles)
早几年停止更新了

论坛徽章:
0
13 [报告]
发表于 2007-04-24 13:12 |只看该作者
下了个httpwatch
看网业post信息确实只有
ekey ''
user_type 1
pass_word 835170
user_name thevoice

四个变量
地址也是post到了 http://www.cmfu.com/loginuser.asp

为什么print $res->content  就是body为空呢

  1. <body leftMargin=5 topMargin=0 bgcolor="#ffffff">

  2. <script>window.location.href = '';</script><!--尝试关闭未关闭的数据库-->
复制代码

哪里出错了 真搞不懂

论坛徽章:
0
14 [报告]
发表于 2007-04-24 13:32 |只看该作者
嗯,试了下。loginuser.asp要检查ASPSESSIONIDAQBSSRSD
步骤是这样的1.GET index.asp, 保存cookie
2.带cookie, POST
3. 再更新cookie, GET你要的叶面。

这是我的代码。测试是成功的

  1. my $url = 'http://www.cmfu.com/index.asp';
  2. my $lurl = 'http://www.cmfu.com/loginuser.asp';
  3. my %form = (ekey => '', user_type => '1', pass_word => '835170', user_name => 'thevoice');
  4. my %header = (Referer => $url);
  5. my ($html, $cookie) = http_get($url, \%header);
  6. $header{Cookie} = $cookie if ($cookie);
  7. ($html, $cookie) = http_post($lurl, \%header, \%form);
  8. $header{Cookie} .= ';'.$cookie if ($cookie);
  9. ($html) = http_get($url, \%header);
  10. print $html;
复制代码

[ 本帖最后由 路小佳 于 2007-4-24 13:39 编辑 ]

论坛徽章:
0
15 [报告]
发表于 2007-04-24 13:38 |只看该作者
use LWP的话, cookie_jar一下应该就可以了。(猜的, 不确定).

论坛徽章:
1
2015年辞旧岁徽章
日期:2015-03-03 16:54:15
16 [报告]
发表于 2007-04-24 13:38 |只看该作者
原帖由 路小佳 于 2007-4-24 13:38 发表
use LWP的话, cookie_jar一下应该就可以了。(猜的, 不确定).

我帮你确定。

论坛徽章:
0
17 [报告]
发表于 2007-04-24 17:35 |只看该作者
还是不行,现在得到的结果说是没有这个用户,是不是我cookie那里处理的有问题?
还有如果我想查看cookie的值 怎么print出来呢?
print $ua->cookie_jar;
得到的是 http::cookie hash 后面一堆

  1. #! /usr/perl/bin
  2. use strict;
  3. use warnings;

  4. use LWP::UserAgent;
  5. use HTTP::Request::Common qw(POST GET);


  6. my %ua_option = (
  7.     agent => "Mozilla/5.0",
  8.     timeout => 180,
  9. );

  10. my $ua = LWP::UserAgent->new(%ua_option);

  11. $ua->cookie_jar({ file => "$ENV{HOME}/.cookies.txt,autosave => 1, ignore_discard => 1" });
  12. my $lurl = 'http://www.cmfu.com/loginuser.asp'; # or 'https://...';
  13. my $url = 'http://www.cmfu.com/index.asp';

  14. my %form;
  15. $form{user_name} = 'the_voice';
  16. $form{pass_word} = '835170';
  17. $form{ekey}='';
  18. $form{user_type}=1;

  19. my $req = GET $url;
  20. my $res = $ua->request($req);

  21. $ua->cookie_jar->extract_cookies($res);
  22. $req  = POST($lurl, [%form]);
  23. $res = $ua->request($req);
  24. $ua->cookie_jar->extract_cookies($res);
  25. if ($res->is_success) {
  26.         print $res->content;
  27. }else{
  28.         print $res->status_line . "\n";
  29. }
复制代码

论坛徽章:
0
18 [报告]
发表于 2007-04-24 17:37 |只看该作者
LWP我不熟, 爱莫能助。

论坛徽章:
0
19 [报告]
发表于 2007-04-24 17:48 |只看该作者
原帖由 路小佳 于 2007-4-24 13:32 发表
嗯,试了下。loginuser.asp要检查ASPSESSIONIDAQBSSRSD
步骤是这样的1.GET index.asp, 保存cookie
2.带cookie, POST
3. 再更新cookie, GET你要的叶面。

这是我的代码。测试是成功的
[code]
my $url = 'ht ...


你的代码我perl不成功
Undefined subroutine &main::http_get called at D:\perl\cmfu.pl line 5.

activeperl + win

论坛徽章:
0
20 [报告]
发表于 2007-04-24 17:54 |只看该作者
http_get是我封装的Net::HTTP的一个函数。(写的很烂, 不好意思献丑)

你这么一说, 我想起来了。LWP也是基于Net::HTTP的, 有个BUG.
就是当服务器返回多个Set-Cookie头时, 如果用Net::HTTP的示例代码的话只能读到一个

  1. my($code, $mess, %h) = $s->read_response_headers;
复制代码

我封装是是这样调用的

  1. my($code, $mess, @h) = $s->read_response_headers;
复制代码

然后手动处理, 你用sniffer试下, 可能是这个Bug的问题。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP