-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathradon_writer.rb
61 lines (50 loc) · 1.56 KB
/
radon_writer.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
require 'mechanize'
require 'httparty'
class RadonWriter
def initialize
@mechanize = Mechanize.new
@username = 'p2433'
@password = 'harper'
@code = 'aa4bca69-ce62-4182-a2e0-f594c3d3052c'
end
def login
page = @mechanize.get('http://3pcmc.pillartopost.com/standard/login.aspx')
form = page.forms.first
@viewstate = form['__VIEWSTATE']
@viewstategenerator = form['__VIEWSTATEGENERATOR']
data = { :body => {
__VIEWSTATE: @viewstate,
__VIEWSTATEGENERATOR: @viewstategenerator,
txtUsername: @username,
txtPassword: @password,
btnSubmit: 'Submit'
}}
inspections = HTTParty.post('http://3pcmc.pillartopost.com/standard/login.aspx', data)
print inspections
end
def search_todays_inspections
data = { :body => {
'__EVENTTARGET' => 'lkbEvent',
'__EVENTARGUMENT' => 'RunSearch',
'__VIEWSTATE' => @viewstate,
'__VIEWSTATEGENERATOR' => @viewstategenerator,
'ctl00$mainContent$txtSearch' => '',
'ctl00$mainContent$lstInspectors' => @code,
'ctl00$mainContent$txtAgent' => '',
'ctl00$mainContent$hdnAgentId' => '0',
'ctl00$mainContent$txtFromDate' => '01/08/2016',
'ctl00$mainContent$hdnDateFrom' => '',
'ctl00$mainContent$txtToDate' => '01/08/2016',
'ctl00$mainContent$hdnDateTo' => '',
'ctl00$mainContent$lstStatus' => '2',
'tblListOfInspections_length' => '100',
'ctl00$hidRole' => 'False'
}}
page = HTTParty.post('http://3pcmc.pillartopost.com/authenticated/inspections/home.aspx', data)
print page
#print page.headers.inspect
end
end
app = RadonWriter.new
app.login
#app.search_todays_inspections