Created
February 14, 2013 08:10
-
-
Save lazywei/4951270 to your computer and use it in GitHub Desktop.
自動抓取 emome 上未出帳的每月上網使用流量
This file contains 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
# 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