Sha256: fda4feb1e98d1f51b025cc56edbdacfa3a1ff2eee7551d65e3ffe2b1f7ba682b

Contents?: true

Size: 910 Bytes

Versions: 1

Compression:

Stored size: 910 Bytes

Contents

#!/usr/bin/env ruby
#
# points-anamileage.rb: getting current mileage
# by scraping www.ana.co.jp.
#
# Copyright (C) 2012 by MATSUI Shinsuke <poppen.jp@gmail.com>
# Distributed under GPL.
#

require 'rubygems'
require 'mechanize'
require 'pit'

URL = 'https://www.ana.co.jp/'

@login = Pit::get( 'ana', :require => {
	'user' => 'your ID of ana.',
	'pass' => 'your Password of ana.'
} )

agent = Mechanize::new
agent.set_proxy( *ENV['HTTP_PROXY'].split( /:/ ) ) if ENV['HTTP_PROXY']

agent.get(URL)

agent.page.form_with(:name => 'loginForm') do|form|
	form.custno = @login['user']
	form.password = @login['pass']
	form.click_button
end

agent.page.forms[0].tap do|form|
	form.encoding = 'CP932'
	form.click_button
end

point = agent.page.at('//div[@class="mileInfo_a2"]//span[1]').text

puts point

# Local Variables:
# mode: ruby
# indent-tabs-mode: t
# tab-width: 3
# ruby-indent-level: 3
# End:
# vim: ts=3

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
points-scraper-0.0.3 bin/points-anamileage