Skip to content

Instantly share code, notes, and snippets.

@sorah
Created June 26, 2010 04:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sorah/453791 to your computer and use it in GitHub Desktop.
Save sorah/453791 to your computer and use it in GitHub Desktop.
<HTML>
<BODY>
<FORM METHOD='POST' ACTION='../servlet/jp.ac.keio.ess.adst.servlet.view.NoLectureCheckServlet?param=adst'>
<TABLE ALIGN='Center'>
<TR><TD><DIV CLASS='DispTitle'>休講・補講情報 確認画面</DIV></TD>
<TD><DIV CLASS='DispTitle'></DIV></TD></TR>
</TABLE>
<BR>
<DIV CLASS='NotandumMessage'>(注意) 掲示板の休講情報/補講情報も確認してください。</DIV>
<HR><TABLE ALIGN='Center'>
<TR><TD><TT><DIV CLASS='Message'> </DIV></TT></TD></TR>
</TABLE>
<HR>
<TABLE ALIGN='Center'>
<TR>
<TD ALIGN='Center'>
<B>自分の履修科目に関する、</B><B>今日(0000-00-00)から1ヶ月後(2010-00-00)までの</B><SPAN CLASS='Lecture'>休講情報</SPAN>
<BR>
</TD>
</TR>
<TR><TD ALIGN='Center'>
<TABLE>
<TR CLASS='ResultItems'>
<TD ALIGN='Center'>
<TABLE BORDER='1' RULES='all'>
<TR>
<TH>年月日</TH>
<TH>曜時</TH>
<TH>地区</TH>
<TH>科目名</TH>
<TH>担当者</TH>
<TH>備考</TH>
</TR>
<TR>
<TD>0000-00-00</TD>
<TD>滅1</TD>
<TD>関東</TD>
<TD>foobar破滅論</TD>
<TD>Hoge Hoge Huga Bar</TD>
<TD>破滅しました。</TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD>
<BR>
</TD>
</TR>
<TR>
<TD ALIGN='Center'><B>自分の履修科目に関する、</B><B>今日(2010-06-26)から1ヶ月後(2010-07-27)までの</B><SPAN CLASS='Lecture'>補講情報</SPAN><BR>
</TD>
</TR>
<TR>
<TD ALIGN='Center'>
<TABLE>
<TR CLASS='ResultItems'>
<TD ALIGN='Center'>
<TABLE BORDER='1' RULES='all'>
<TR>
<TH>補講年月日</TH>
<TH>補講曜時</TH>
<TH>地区</TH>
<TH>科目名</TH>
<TH>担当者</TH>
<TH>補講教室</TH>
<TH>対象休講日</TH>
<TH>備考</TH>
</TR>
<TR>
<TD>9999-00-00</TD>
<TD>破3</TD>
<TD>北極</TD>
<TD>foobar破滅論</TD>
<TD>Hoge Hoge Huga Bar</TD>
<TD>000</TD>
<TD>復帰したよ!</TD>
<TD>
</TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD>
<BR>
</TD>
</TR>
<TR>
<TD ALIGN='Center'>
<INPUT VALUE='検索条件設定画面へ戻る' TYPE='SUBMIT' NAME='ALC002PbReturnALC001'>
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
#-*- coding: utf-8 -*-
require 'rubygems'
require 'mechanize'
class NoLectureInformation
def initialize(h={})
@h = h
if h.key?(:date) && h.key?(:time) \
&& h.key?(:place) && h.key?(:name) \
&& h.key?(:lectureer) && h.key?(:note)
raise ArgumentError, "needs date,time,place,name,lectureer,note"
end
h.each do |k,v|
raise ArgumentError, "Should kind of String" unless v.kind_of?(String)
eval "@#{k} = #{v.inspect}"
end
end
def inspect
@h.inspect
end
attr_reader :date, :time, :place, :name, :lectureer, :note
end
def putatu(a)
puts "#{agent.page.title||""} - #{agent.page.uri||""}"
rescue; nil
end
agent = Mechanize.new
agent.get('https://login.keio.jp/koid/')
agent.page.form_with(:action => 'login') do |form|
form.field_with(:name => 'SignOnID').value = "my user ID"
form.field_with(:name => 'Passwd').value = "my passwd"
form.click_button
end
putatu(agent)
agent.page.form_with(:action => 'https://www2.adst.keio.ac.jp/rishu/servlet/'
+ 'jp.ac.keio.ess.adst.servlet.view.PortalAuthenticateServlet') do |form|
form.click_button
end
putatu(agent)
agent.page.form_with(:action => '../servlet/jp.ac.keio.ess.adst.servlet.view.GakujiTopMen'
+ 'uServlet?param=adst') do |form|
form.click_button(form.button_with(:name => 'ATM001PbNoLectureCheck'))
end
putatu(agent)
agent.page.form_with(:action => '../servlet/jp.ac.keio.ess.adst.'
+ 'servlet.view.NoLectureCheckServlet?param=adst') do |form|
form.click_button
end
putatu(agent)
r = agent.page.search('tr.Message').inner_text
abort "Lectures are going to done normally" if r.include?("休講情報はありません")
is = agent.page.search('tr.ResultItems tr')
nris = []
is.each do |i|
break if /補講情報/ ~= i.parent.parent.parent \
.parent.parent.parent.parent \
.search('tr')[0].inner_text
attrs = i.search('th')
nris << NoLectureInformation.new(
:date => attrs[0]
:time => attrs[1]
:place => attrs[2]
:name => attrs[3]
:lectureer => attrs[4]
:note => attrs[5]
)
end
nris.map(&:inspect){|n| puts n}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment