lib/lwqzx.rb in lwqzx-0.0.4 vs lib/lwqzx.rb in lwqzx-0.0.5

- old
+ new

@@ -5,18 +5,18 @@ def self.auth(login,passwd) lurl = "http://www.lwqzx.sdedu.net/kernel/net_school/active_app/login1.php" user = "login_user_m_=#{login}" psd = "login_password=#{passwd}" res = %x[curl #{lurl} -s -c /tmp/cookies -d #{user} -d #{psd} ] - aurl = "http://www.lwqzx.sdedu.net/kernel/net_school/islogin.php" - ares = %x[curl -s -b /tmp/cookies #{aurl}] - return {} if ares.to_s == "0" infos = %x[curl -s -b /tmp/cookies #{lurl}] content=infos.encode("UTF-8","GB2312") doc = Nokogiri::HTML(content) uname = doc.css("span.tt1 a:nth-child(1)").text + return {} if uname == "" groups = doc.css("span.tt1 a:nth-child(5)")[0]["title"] %x[rm /tmp/cookies] groups=groups.gsub("[","").gsub("]","").split("@").compact.reject(&:empty?) return {login: login, name: uname, groups: groups} end end + +Lwqzx.auth("dsfas","dsfasd")