Sha256: 21a54c18b639411cf09f35dbf2241bdc94f41cba76cc6afe9a2e7ee24faee094
Contents?: true
Size: 867 Bytes
Versions: 1
Compression:
Stored size: 867 Bytes
Contents
require "lwqzx/version" require 'nokogiri' module Lwqzx 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 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
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lwqzx-0.0.4 | lib/lwqzx.rb |