#! /Usr/bin/perl-W
Use strict;
Use lwp;
Use http: Request: Common QW (Post get );
Use http: cookies;
Use lwp: useragent;
Use lwp: simple;
Use URI: URL;
My $ UA = lwp: useragent-> new;
$ UA-> agent ("Mozilla 1.503 Windows XP ");
$ UA-> cookie_jar (http: cookies-> New (file => "bankcookies.txt", autosave => 1 ));
My $ url = "http://www.ebigear.com/login.html ";
My $ Req = post $ URL, [membername => "thinkhy", Pwd => "******"];
My $ response = $ UA-> request ($ req );
Die "can't get $ URL --", $ response-> status_line
Unless $ response-> is_success;
Die "hey, I was expecting HTML, not", $ response-> content_type
Unless $ response-> content_type EQ 'text/html ';
My $ loginreq = $ response-> content;
If ($ loginreq = ~ M/success/SG ){
Print "Logon successful \ n ";
}
Else {
Print "Logon Failed \ n ";
}
# Print $ response-> head;
# Header
My @ ns_headers = (
);
$ Response = $ UA-> get ('HTTP: // www.ebigear.com/resdown-1393-7777700044624.html', @ ns_headers );
My $ content = $ response-> content;
If ($ content = ~ M/because you are not logged on/SG ){
Print "Ah, cannot get MP3 address \ n ";
}
Else {
Print "successfully obtained MP3 address \ n ";
}
If ($ content = ~ M/(<Div class = "DownLoadURL"> ).*? "(Ftp :\/\/.*?) "/SG ){
Print "get it: $2 \ n ";
$ Url = $2;
My ($ user, $ password, $ site, $ path, $ file) = ($ url = ~ /^ Ftp :\/\/(.*?) :(.*?) @(.*?) (\/. *) \/(. *) $/S );
Print "User: $ user \ npwd: $ password \ nsite: $ site \ npath: $ path \ nfile: $ file \ n ";
If ($ UA-> is_protocol_supported ('ftp '))
{
Print "\ n supported ";
$ Response = $ UA-> get ($ URL, @ ns_headers );
Print "$ URL ";
Getstore $ URL, "1.mp3 ";
}
# My $ FTP;
# $ FTP = net: ftp-> New ("$ site", DEBUG => 0)
# Or die "cannot connect to $ site: $ @";
# $ FTP-> login ("$ user", "$ password ")
# Or die "cannot login", $ FTP-> message;
# $ FTP-> CWD ("$ path ")
# Or die "cannot change working directory", $ FTP-> message;
# $ FTP-> get ($ file)
# $ FTP-> get ("ftp: // 18_zhi: www.daerduo.cn \ @ playjd.teacherhome.cn: 181/c77e/SID-H777/sid77777/RID-TT5/7777700044624tqyp. MP3 ")
# Or die "Get File failed", $ FTP-> message;
# $ FTP-> quit;
}