lib/remora.rb in remora-0.0.1 vs lib/remora.rb in remora-0.0.2

- old
+ new

@@ -29,14 +29,18 @@ doc.css(sel).text() end def reports_left resp = @agent.get("http://www.propertyshark.com/mason/Accounts/My/") doc = Nokogiri::parse(resp.body) - doc - .css(".my-subscriptions")[0] - .css(".details span")[-3] - .text().strip + begin + doc + .css(".my-subscriptions")[0] + .css(".details span")[-3] + .text().strip + rescue NoMethodError => error + "0/200" + end end def search_in_sf(address) response = @agent.get("http://www.propertyshark.com/mason/ca/San-Francisco-County/Property-Search") search_form = { search_type:"address", @@ -107,10 +111,26 @@ search_types_selector:"owner", search_token: name, location:"San Francisco County, CA" } + request_search_by_name(search_form) + end + def search_by_name_in_la(name) + response = @agent.get("http://www.propertyshark.com/mason/ca/Los-Angeles-County/Property-Search") + + search_form = { + search_type:"owner", + search_types_selector:"owner", + search_token: name, + location:"Los Angeles County, CA" + } + request_search_by_name(search_form) + end + + private + def request_search_by_name(search_form) resp = @agent.post("http://www.propertyshark.com/mason/UI/homepage_search.html",search_form) doc = Nokogiri::parse(resp.body) results = doc.search(".owner_table tr.odd, .owner_table tr.even").reject{ |r| r[:style]=~/display:none/ } @@ -118,9 +138,10 @@ results.map do |result| { address: result.css("td.first span.big_font").text().strip(), + city: (result.css("td.first b").text().split(",").shift()||"").strip(), owner: result.css(".single_line:first-child").text().strip() } end end end