- 论坛徽章:
- 0
|
- #!/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();
复制代码 |
|