Chinaunix
标题:
如何自动登录一个web系统,然后post提交数据
[打印本页]
作者:
99超人
时间:
2016-11-26 15:04
提示:
作者被禁止或删除 内容自动屏蔽
作者:
Perl_Er
时间:
2016-11-26 18:43
use strict;
use warnings;
use utf8;
use LWP::UserAgent;
use Data::Dumper;
my $ua = LWP::UserAgent->new;
$ua->timeout(10);
$ua->env_proxy;
my $req = HTTP::Request->new(GET => "http://rabbitmq01.sample.net:15672/api/vhosts");
$req->authorization_basic('guest', 'guest');
print $ua->request($req)->as_string;
复制代码
作者:
Perl_Er
时间:
2016-11-26 18:46
#!/usr/bin/perl
use strict;
use warnings;
use HTTP::Request;
use HTTP::Cookies;
use LWP::UserAgent;
my $url = 'http://passport.renren.com/PLogin.do';
# 用来存 cookie
my $cookie_jar = HTTP::Cookies->new(
file => "./acookies.lwp",
autosave => 1,
);
# 给处理 cookie 的对象放到 LWP::UserAgent 中来处理 cookie
# 登陆中
my $ua = LWP::UserAgent->new;
my $cookies = $ua->cookie_jar($cookie_jar);
$ua->agent('Mozilla/9 [en] (Centos; Linux)');
my $res = $ua->post(
$url,
[
email => 'username@gmail.com',
password => 'passwd',
# origURL => 'http//www.renren.com/home',
# domain => 'renren.com',
],
);
#Now you can access your protected content
#$res =$ua->get('http://www.renren.com/home.do');
$res = $ua->get(
'http://blog.renren.com/blog/702740495/932392877?myblog'
);
print $res->content();
复制代码
作者:
99超人
时间:
2016-11-27 06:42
提示:
作者被禁止或删除 内容自动屏蔽
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2