-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbn.rb
38 lines (30 loc) · 858 Bytes
/
bn.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require 'rubygems'
errors = []
%w(mechanize hpricot growl iconv).each do |gem|
begin
require gem
rescue LoadError
errors << gem
end
end
puts errors
class Symbol
def to_proc
sym = self
lambda{|obj| obj.send sym}
end
end
form = Mechanize.new.get('http://users.idom.by/').forms.first
form.login = ARGV[0]
form.passwd = ARGV[1]
data = Hpricot(form.click_button.body).search('table')
balance = data.search('tr')[3].search('td').html.gsub(/[^0-9,]/, "").to_i
name = data.search('tr')[1].search('td').html
tarif = data.search('tr')[2].search('td').html
message = ''
message << Iconv.iconv('utf-8', 'cp1251', name).join() + '
'
message << Iconv.iconv('utf-8', 'cp1251', tarif).join() + '
'
message << [ "Баланс: #{(balance - (12 * 1000)) / 3300} дня!"].join()
Growl.notify message