Class: Points::Scraper::AnaMileage

Inherits:
Default
  • Object
show all
Defined in:
lib/points-scraper/anamileage.rb

Constant Summary collapse

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

Instance Method Summary collapse

Methods inherited from Default

#initialize

Constructor Details

This class inherits a constructor from Points::Scraper::Default

Instance Method Details

#startObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/points-scraper/anamileage.rb', line 15

def start
	start_scrape do |agent|
		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 = @user
			form.password = @pass
			form.click_button
		end

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

		agent.page.at('ul.point-list a').text.gsub(/,/, '')
	end
end