Skip to content

Instantly share code, notes, and snippets.

@lajunta
Created November 17, 2016 12:58
Show Gist options
  • Save lajunta/5c8db8d4a6e6c9da25dd2b880f25925f to your computer and use it in GitHub Desktop.
Save lajunta/5c8db8d4a6e6c9da25dd2b880f25925f to your computer and use it in GitHub Desktop.
require "restclient"
require "json"
#@keyword = URI::decode("新闻快讯")
@keyword = "学校公告"
start = '0'
lmt = '10'
@kword = @keyword.encode("GB2312","UTF-8")
kword = URI::encode(@kword)
lurl = "http://www.lwqzx.sdedu.net/kernel/net_school/active_app/login1.php"
user = "login_user_m_=ftuo"
psd = "login_password=fengtuo"
res = RestClient.post(lurl,{login_user_m_: "xxx",login_password: "xxx"})
cook = res.cookies
puts cook
aurl = "http://www.lwqzx.sdedu.net/kernel/net_school/islogin.php"
ares = RestClient.get(aurl,{cookies: cook})
puts ares.to_s
murl = 'http://www.lwqzx.sdedu.net/m/net_school/docs/api.php?op=list_json&kword='+kword+'&start='+start+'&lmt='+lmt+'&width=42'
infos1 = RestClient.get(murl,{cookies: cook}).body
content1=infos1.encode("UTF-8","GB2312")
puts JSON.parse(content1).second
# %x[rm /tmp/cookies]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment