加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

用Perl实现网站自动登录

发布时间:2020-12-16 00:31:18 所属栏目:大数据 来源:网络整理
导读:#!/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 ? W
#!/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/成功/sg) { ?? ?print "登录成功n"; } else { ?? ?print "登录失败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/因您未登录/sg) { ?? ?print "哎,不能获取到mp3地址n"; } else { ?? ?print "成功获取到mp3地址n"; } if ($content =~ m/(<div class="downloadurl">).*?"(ftp://.*?)"/sg) { ?? ?print "get it: $2n"; ?? ?$url = $2; ?? ?my($user,$password,$site,$path,$file) = ($url =~ /^ftp://(.*?):(.*?)@(.*?)(/.*)/(.*)$/s);? ?? ?print "user:$usernpwd:$passwordnsite:$sitenpath:$pathnfile:$filen"; ?? ?if ($ua->is_protocol_supported('ftp')) ?? ?{ ?? ? ? ?print "支持n"; ?? ? ? ?$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/RID-H47/7777700044624tqyp.MP3") # ? ? ?or die "get file failed ",$ftp->message; # ? ?$ftp->quit; }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读