Skip to content

Instantly share code, notes, and snippets.

@lazywei
Created February 14, 2013 08:10
Show Gist options
  • Save lazywei/4951270 to your computer and use it in GitHub Desktop.
Save lazywei/4951270 to your computer and use it in GitHub Desktop.
自動抓取 emome 上未出帳的每月上網使用流量
# encoding: UTF-8
require "nokogiri"
require "mechanize"
p "Phone number:"
uid = gets.chomp
p "Password:"
pw = gets.chomp
base_url = "http://bms.emome.net/proxy/mbms/"
agent = Mechanize.new
page = agent.get("#{base_url}service.jsp?leftmenu=bill&url=notPayBill.jsp")
form = page.form_with(:name => "form1")
form.uid = uid
form.pw = pw
form.submit
page = agent.get("#{base_url}service.jsp?leftmenu=bill&url=notPayBill.jsp")
page = agent.get("" + (/href='(.*)';/).match(page.at('body')['onload'])[1])
doc = Nokogiri::HTML(page.body)
p doc.css('table.f09-01 tr[bgcolor="#DEEFFF"] td').last.content
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment