CnUnix

[알림판목록 I] [알림판목록 II] [글목록][이 전][다 음]
[ CnUnix ] in KIDS
글 쓴 이(By): wang (Chip쟁이)
날 짜 (Date): 2002년 6월 18일 화요일 오후 03시 21분 54초
제 목(Title): Re: [Q] 펄로 쿠키 가져오기...


#!/opt/gnu/bin/perl -w

use HTTP::Headers;
use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
use HTTP::Cookies;
use LWP::Simple;

$ua = LWP::UserAgent->new();
$cookie_jar = HTTP::Cookies->new(
        File     => "/export/home/wang/beetle/cookies",
        AutoSave => 1);

my $req0 = POST "http://some.site.kr/examples/servlet/login",
        [ f_name => 'Login',
        id => 'userid',
        password => "XXXXXXXX"];
my $ret = $ua->request($req0);

$cookie_jar->extract_cookies($ret);
$cookie_jar->save;

$req1 = HTTP::Request->new(GET => "http://some.site.kr/examples/servlet/body");
$cookie_jar->add_cookie_header($req1);

$content1 = $ua->request($req1);

$req1 = HTTP::Request->new(GET => "http://some.site.kr/examples/servlet/twotier_frame?option=AAAA\&option_sub=edms");
$cookie_jar->add_cookie_header($req1);

$content1 = $ua->request($req1);

----------------------------------------------------------

어떤 website에 login하고 쿠키를 받아와서 계속 그 쿠키로 꿍짝꿍짝하는 예제입니다.


[알림판목록 I] [알림판목록 II] [글 목록][이 전][다 음]
키 즈 는 열 린 사 람 들 의 모 임 입 니 다.