UserAgent - Problem to logon to ASP server
Релиб
Форумы       Участники    Календарь    Кто он-лайн?
Добро пожаловать, гость ( Вход | Регистрация )
        



UserAgent - Problem to logon to ASP server Expand / Collapse
Автор
Сообщение
09.05.2002 23:07
новичок

новичокновичокновичокновичокновичокновичокновичокновичок

участник
Last Login: 18.10.2006 1:04
Сообщ.: 3, Visits: 35
V silu obstoyatel'stv vinuzhden zapolnyat' mnogo form
Reshil avtomatizirovat' process - no ne mogu sdelat' logon na server
Vot kod scripta - imya servera, login i pasw - real'nie
----------------------------------------------------------------
#!/usr/bin/perl -w

use LWP::UserAgent;
use HTTP::Request;
use HTTP::Request::Common qw(POST);
use HTTP::Response;
use URI::Heuristic;
use HTTP::Cookies;

my $raw_url = 'www.************.com/admin';

open( OUTPUT, ">request.res") || die "File request.res can't be opened";
my $url = URI::Heuristic::uf_urlstr($raw_url);
$| = 1; # to flush next line
my $ua = LWP::UserAgent->new();

my $init_req = HTTP::Request->new(GET => $url);

my $response = $ua->request($init_req);
if ($response->is_error())
{
printf " %s", $response->status_line;
}
else
{
$init_cookie= HTTP::Cookies->new;
$init_cookie->extract_cookies($response);
$content = $response->as_string;
print OUTPUT $content;
}

$| = 1;
$login_req = POST 'http://www.**************.com/admin/index.asp',
[ UserName => '++++++++',
Password => '@@@@@@@@@',
action => 'Login'];
$init_cookie->add_cookie_header($login_req);

$req_txt = $login_req->as_string();
print OUTPUT $req_txt;

$response = $ua->request($login_req);
if ($response->is_error())
{
printf " %s", $response->status_line;
}
else
{
$content = $response->as_string;
print OUTPUT $content;
}
----------------------------------------------------------------
Vot kakoi otvet ya poluchayu:

http://www.smilephotovideo.com/admin/admin_dblist.asp
Content-Length: 57
Content-Type: application/x-www-form-urlencoded
Cookie: ASPSESSIONIDGGGGGYQC=AJGDNIGANJLGIDMIKACNFKEI
Cookie2: $Version=1

UserName=+++++++++&Password=@@@@@@@@@@@&action=Login
HTTP/1.1 302 (Found) Object moved
Cache-Control: private
Connection: Keep-Alive
Date: Wed, 08 May 2002 16:59:39 GMT
Location: index.asp
Server: Microsoft-IIS/5.0
Content-Length: 130
Content-Type: text/html
Expires: Wed, 08 May 2002 16:59:40 GMT
Client-Date: Wed, 08 May 2002 16:48:47 GMT
Client-Peer: 209.125.209.156:80
Title: Object moved

<head><title>Object moved</title></head>
<body><h1>Object Moved</h1>This object may be found <a HREF="admin_dblist.asp">here</a>.</body>

-------------------------------------------------------------
Vopros - chego emu escho nado - mozhet kto znaet pokakomu printsipu on fil'truet ?
Сообщ. #749427
« пред. тема | след. тема »


Эту тему читают Expand / Collapse
Посетители: 0 (0 гостей, 0 участников, 0 скрыт.участников)
Сейчас нет участников, просматривающих тему.
Модераторы: Alexey, boombastik, bazile, pl

Время GMT +3:00, Сейчас 10:51