Created
March 11, 2015 20:02
-
-
Save thataustin/07468c28cf05d606ee6b to your computer and use it in GitHub Desktop.
Scraping CA NOI's
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'mechanize' | |
require 'byebug' | |
a = Mechanize.new { |agent| | |
agent.user_agent_alias = 'Mac Safari' | |
key = 'JSESSIONID' | |
value = '3a70858e14aca4f6aac9ec59d95d13d86e0b4e755b40b67bb56f96f27fbf05b2.e3qSc3iTc34Oe3iNaO0' | |
cookie = Mechanize::Cookie.new(key, value) | |
cookie.domain = "smarts.waterboards.ca.gov" | |
cookie.path = "/smarts" | |
agent.cookie_jar.add(cookie) | |
} | |
postVars = { | |
'form1:searchButton' => 'Search', | |
'form1:selectOneMenu1' => 6021, | |
'form1:regMeasId' => nil, | |
'form1:processedFromDate' => nil, | |
'form1:processedToDate' => nil, | |
'form1:wdid' => nil, | |
'form1:ownerName' => nil, | |
'form1:selectOneMenu2' => 0, | |
'form1:ownerStreet' => nil, | |
'form1:selectOneMenu4' => 0, | |
'form1:devName' => nil, | |
'form1:facilityName' => nil, | |
'form1:sicCode' => nil, | |
'form1:facilityStreet' => nil, | |
'form1:selectOneMenu3' => 4, | |
'form1:facilityCity' => nil, | |
'com.sun.faces.VIEW' => '_id62823:_id62824', | |
'form1' => 'form1' | |
} | |
url = 'https://smarts.waterboards.ca.gov/smarts/faces/PublicDataAccess/PublicNoiSearch.jsp'; | |
page = a.post(url, postVars) | |
hiddenForm = page.form_with(:id => 'form1') | |
links = page.links.select { |link| link.text == 'NOI Form' } | |
links.each { |link| | |
uglyJs = link.attributes.attributes['onclick'].value | |
submitData = { | |
'com.sun.faces.VIEW' => '_id62823:_id62827', | |
'form1' => 'form1', | |
'regMeasId' => 453212 | |
'form1:_idcl' => 'form1:publicSearchNOItable:19:_id27' | |
} | |
} | |
byebug | |
# | |
puts 'hella' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment