bankcrawlers-hapoalim 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +1 -0
- data/bank-crawlers-hapoalim.gemspec +29 -0
- data/lib/bank_crawlers/hapoalim/cache.rb +27 -0
- data/lib/bank_crawlers/hapoalim/crawler.rb +48 -0
- data/lib/bank_crawlers/hapoalim/monkey_patches.rb +16 -0
- data/lib/bank_crawlers/hapoalim/parser.rb +44 -0
- data/lib/bank_crawlers/hapoalim/runner.rb +27 -0
- data/lib/bank_crawlers/hapoalim/version.rb +5 -0
- data/lib/bank_crawlers/hapoalim.rb +13 -0
- data/run.rb +9 -0
- metadata +156 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d925c4f6ff1cf78dcc6d689bb1bfd68f30e14aaa
|
4
|
+
data.tar.gz: 10fdb1093461b600231473eb1837171539a3fb0f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0316a5031c299524774b2ad0e6f7f9d167ad6cc8cb6b4cb36a4bb9cc585316f24ba9c3150bb5b7fb3102face5c434e03b1285b39b6da3bb0c65b6ea4c138097b
|
7
|
+
data.tar.gz: 0697604604b98776d6d4ebb0e3ba31105b098da1a79e499b1434abc4bb695914c4a0cb21cd8b8cbad425dee6e92fae83774d86d485b656b30c068e45f4e890cc
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Maiz Lulkin
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Bank::Crawlers::Hapoalim
|
2
|
+
|
3
|
+
A (crappy) crawler for the (crappy) Hapoalim online interface.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'bank-crawlers-hapoalim'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install bank-crawlers-hapoalim
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
BankCrawlers::Hapoalim.run "USER", "TEUDAT ZEUT", "PASSWORD"
|
23
|
+
```
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "bankcrawlers-hapoalim"
|
7
|
+
spec.version = '0.0.5'
|
8
|
+
spec.authors = ["Maiz Lulkin"]
|
9
|
+
spec.email = ["maiz@lulk.in"]
|
10
|
+
spec.description = %q{A crappy crawler for a crappy bank interface}
|
11
|
+
spec.summary = %q{A crappy crawler for a crappy bank interface}
|
12
|
+
spec.homepage = ""
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files`.split($/)
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
21
|
+
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec", "~>2.14"
|
24
|
+
spec.add_development_dependency "vcr"
|
25
|
+
|
26
|
+
spec.add_dependency "capybara"
|
27
|
+
spec.add_dependency "poltergeist"
|
28
|
+
spec.add_dependency "hpricot"
|
29
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module BankCrawlers::Hapoalim
|
2
|
+
|
3
|
+
class Cache
|
4
|
+
|
5
|
+
def get
|
6
|
+
todays_transaction_table_file.read if todays_transaction_table_file.exist?
|
7
|
+
end
|
8
|
+
|
9
|
+
def set transaction_table
|
10
|
+
FileUtils.makedirs(dir)
|
11
|
+
File.write todays_transaction_table_file, transaction_table
|
12
|
+
transaction_table
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def todays_transaction_table_file
|
18
|
+
Pathname "tmp/transactions-#{Date.today}.html"
|
19
|
+
end
|
20
|
+
|
21
|
+
def dir
|
22
|
+
"tmp"
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'capybara/poltergeist'
|
2
|
+
|
3
|
+
module BankCrawlers::Hapoalim
|
4
|
+
|
5
|
+
class InvalidCredentials < StandardError
|
6
|
+
end
|
7
|
+
|
8
|
+
class Crawler
|
9
|
+
include Capybara::DSL
|
10
|
+
|
11
|
+
BASE_URL = "https://login.bankhapoalim.co.il/cgi-bin/poalwwwc"
|
12
|
+
@@urls = {
|
13
|
+
login: "/?language=EN&nls=EN"
|
14
|
+
}
|
15
|
+
|
16
|
+
attr_reader :user_name, :user_id, :password
|
17
|
+
def initialize user_name, user_id, password
|
18
|
+
@user_name, @user_id, @password = [user_name, user_id, password]
|
19
|
+
Capybara.run_server = false
|
20
|
+
Capybara.current_driver = :poltergeist
|
21
|
+
Capybara.app_host = BASE_URL
|
22
|
+
end
|
23
|
+
|
24
|
+
def transaction_table
|
25
|
+
login
|
26
|
+
iframe_body
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def login
|
32
|
+
visit @@urls[:login]
|
33
|
+
fill_in :userid, with: user_name
|
34
|
+
fill_in :id, with: user_id
|
35
|
+
fill_in :password, with: password
|
36
|
+
|
37
|
+
click_button 'Sign In'
|
38
|
+
sleep 10
|
39
|
+
raise InvalidCredentials if page.body =~ /Welcome to Hapoalim online/
|
40
|
+
end
|
41
|
+
|
42
|
+
def iframe_body
|
43
|
+
within_frame "BODY" do
|
44
|
+
return page.body
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'hpricot'
|
2
|
+
|
3
|
+
module BankCrawlers::Hapoalim
|
4
|
+
|
5
|
+
Parser = Struct.new :html do
|
6
|
+
def transactions
|
7
|
+
table.map do |row|
|
8
|
+
parse_row(row)
|
9
|
+
end.compact
|
10
|
+
end
|
11
|
+
|
12
|
+
def balance
|
13
|
+
transactions.last[:balance]
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def parse_row row
|
19
|
+
items = row.search('td')
|
20
|
+
puts "ROW ITEMS"
|
21
|
+
puts items.inspect
|
22
|
+
{
|
23
|
+
created_at: items.shift.clean_text.dateify,
|
24
|
+
description: items.shift.clean_text,
|
25
|
+
number: items.shift.clean_text,
|
26
|
+
confirmed_at: items.shift.clean_text.dateify,
|
27
|
+
amount: items.shift.clean_text.numerify,
|
28
|
+
extra_info: items.shift.clean_text,
|
29
|
+
balance: items.shift.clean_text.numerify
|
30
|
+
}
|
31
|
+
rescue
|
32
|
+
nil
|
33
|
+
end
|
34
|
+
|
35
|
+
def table
|
36
|
+
doc.search('.TR_ROW_BANKTABLE')
|
37
|
+
end
|
38
|
+
|
39
|
+
def doc
|
40
|
+
@doc ||= Hpricot(html)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module BankCrawlers::Hapoalim
|
2
|
+
|
3
|
+
Runner = Struct.new :user_name, :user_id, :password do
|
4
|
+
def run
|
5
|
+
parser.transactions
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def parser
|
11
|
+
Parser.new(transactions_html)
|
12
|
+
end
|
13
|
+
|
14
|
+
def transactions_html
|
15
|
+
cache.get or cache.set(crawler.transaction_table)
|
16
|
+
end
|
17
|
+
|
18
|
+
def cache
|
19
|
+
Cache.new
|
20
|
+
end
|
21
|
+
|
22
|
+
def crawler
|
23
|
+
Crawler.new user_name, user_id, password
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module BankCrawlers
|
2
|
+
module Hapoalim
|
3
|
+
def self.run user_name, user_id, password
|
4
|
+
Runner.new(user_name, user_id, password).run
|
5
|
+
end
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
require_relative 'hapoalim/monkey_patches'
|
10
|
+
require_relative 'hapoalim/parser'
|
11
|
+
require_relative 'hapoalim/runner'
|
12
|
+
require_relative 'hapoalim/cache'
|
13
|
+
require_relative 'hapoalim/crawler'
|
data/run.rb
ADDED
metadata
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bankcrawlers-hapoalim
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.5
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Maiz Lulkin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.14'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.14'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: vcr
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: capybara
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: poltergeist
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: hpricot
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: A crappy crawler for a crappy bank interface
|
112
|
+
email:
|
113
|
+
- maiz@lulk.in
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- .gitignore
|
119
|
+
- Gemfile
|
120
|
+
- LICENSE.txt
|
121
|
+
- README.md
|
122
|
+
- Rakefile
|
123
|
+
- bank-crawlers-hapoalim.gemspec
|
124
|
+
- lib/bank_crawlers/hapoalim.rb
|
125
|
+
- lib/bank_crawlers/hapoalim/cache.rb
|
126
|
+
- lib/bank_crawlers/hapoalim/crawler.rb
|
127
|
+
- lib/bank_crawlers/hapoalim/monkey_patches.rb
|
128
|
+
- lib/bank_crawlers/hapoalim/parser.rb
|
129
|
+
- lib/bank_crawlers/hapoalim/runner.rb
|
130
|
+
- lib/bank_crawlers/hapoalim/version.rb
|
131
|
+
- run.rb
|
132
|
+
homepage: ''
|
133
|
+
licenses:
|
134
|
+
- MIT
|
135
|
+
metadata: {}
|
136
|
+
post_install_message:
|
137
|
+
rdoc_options: []
|
138
|
+
require_paths:
|
139
|
+
- lib
|
140
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - '>='
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
requirements: []
|
151
|
+
rubyforge_project:
|
152
|
+
rubygems_version: 2.0.6
|
153
|
+
signing_key:
|
154
|
+
specification_version: 4
|
155
|
+
summary: A crappy crawler for a crappy bank interface
|
156
|
+
test_files: []
|