Last active
December 10, 2015 00:28
-
-
Save keating/4351192 to your computer and use it in GitHub Desktop.
use Mechanize
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| agent = Mechanize.new | |
| page = agent.get('http://....../login') | |
| form = page.forms[0] | |
| form["user_session[login]"] = "......" | |
| form["user_session[password]"] = "......" | |
| form.submit | |
| #puts page.uri | |
| page = agent.get('http://...../synchrons') | |
| #puts page.uri | |
| #puts page | |
| #http://moniter.beiyanght.com/login | |
| syn_his = [] | |
| page.search("table.grid tbody tr").each do |tr| | |
| arr = tr.search("td").inject([]) do |r, td| | |
| r << td.content | |
| r | |
| end | |
| syn_his << arr | |
| end | |
| puts "Today is #{Time.new}, current page syn log count:#{syn_his.count}" | |
| syn_his.each do |his| | |
| puts "#{his[3]},#{his[2]},#{his[1]},#{his[0]}" | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment