perl登录whu选课系统,查看信息等
发布时间:2020-12-15 23:56:53 所属栏目:大数据 来源:网络整理
导读:perl登录whu选课系统,查看信息等 tkorays(tkorays@hotmail.com) 永不停止地奋斗! ??????? 曾想过用命令行来操作选课系统,这看起来多么好玩的一件事
perl登录whu选课系统,查看信息等 tkorays(tkorays@hotmail.com) 永不停止地奋斗! ??????? 曾想过用命令行来操作选课系统,这看起来多么好玩的一件事啊。 ??????? 要实现它,首先要做的就是选课系统的登录,然后是解析页面,获取信息。这些用perl实现是多么简单! ??????? 下面实现了一个简单登录与课表查询,其他功能如查询信息,选课等,道理都是一样的。不是post就是get然后解析。 #!/usr/bin/perl # Copyright 2014 tkorays. All rights reserved. # author tkorays # email tkorays@hotmail.com use strict; use warnings; use LWP; use LWP::Simple; use LWP::UserAgent; use HTTP::Cookies; use HTTP::Headers; use HTTP::Response; use Encode; use URI::Escape; use URI::URL; my $ua = LWP::UserAgent->new; $ua->agent("Mozilla/5.0 (Windows NT 6.1; rv:30.0) Gecko/20100101 Firefox/30.0"); $ua->timeout(100); my $cookie_jar = HTTP::Cookies->new( file=>'lwp_cookies.txt',autosave=>1,ignore_discard=>1); $ua->cookie_jar($cookie_jar); my $whu_id = '你的whu学号'; my $whu_pwd = '你的密码'; my $captcha = ''; my $url = 'http://202.114.74.198'; my $form_submit = encode('gb2312',decode('utf8',"确 定")); my $captcha_url = $url.'/GenImg'; my $pres = $ua->get($captcha_url); open(FILE_HANDLE,'>img.jpg'); binmode FILE_HANDLE; print FILE_HANDLE $pres->content; close FILE_HANDLE; ################################### # input info print 'input your id:',"n"; #chomp($whu_id = <STDIN>); die "n***please input your id***n" unless $whu_id; print 'input your password:',"n"; #chomp($whu_pwd = <STDIN>); die "n***please input your password***n" unless $whu_pwd; print 'input captcha:',"n"; chomp($captcha = <STDIN>); die "n***please input captcha***n" unless $captcha; my $res = $ua->post($url.'/servlet/Login',{ 'who'=>'student','id'=>$whu_id,'pwd'=>$whu_pwd,'yzm'=>$captcha,'submit'=>$form_submit }); if($res->header('Location') eq $url.'/stu/newstu_index.jsp'){ print "login success!n"; }else{ exit; } # get lessons my $lessonpage = $ua->get($url.'/stu/query_stu_lesson.jsp'); die 'failed to open lesson page' unless $lessonpage->is_success; my $pagect = $lessonpage->content; $pagect =~ s/[rnt]/ /g; my $result; my $t = encode('gb2312',"姓名")); $pagect =~ /$t:(.*?)?/; print "nn",encode('gb2312',"姓名")),": $1n"; $t = encode('gb2312',"学号")); $pagect =~ /$t:(.*?)s/; print encode('gb2312',"学号")),": $1n"; print encode('gb2312',"课程")),": n"; my @allmatch = $pagect =~ /<tr[^>]*>(.*?)(?!/tr>)</tr>/g; foreach my $single(@allmatch){ $result = $single =~ /<td width="80">(.*?)(?!/td>)</td>/g; print $1,"n" if $result; } ??????? 填写好密码,找到验证码文件填写好后,运行结果如下: ??????? 之后你就可以为所欲为,编写自己的选课系统功能,自由选课,一键评教,抢课,so easy…… (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |