Skip to content
This repository has been archived by the owner on Dec 26, 2017. It is now read-only.

Commit

Permalink
scrape with Zen-like precision
Browse files Browse the repository at this point in the history
  • Loading branch information
Troy Davis committed Aug 27, 2010
1 parent 05c7271 commit 48eeb94
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/police_report_fetcher.rb
Expand Up @@ -12,7 +12,8 @@ def connection
def crime_request(&block)
connection.post do |req|
req['Content-Type'] = 'application/xml'
req['Origin'] = 'http://web5.seattle.gov/'
req['Cache-Control'] = 'max-age=0'
req['Origin'] = 'http://web5.seattle.gov'
req['Referer'] = 'http://web5.seattle.gov/mnm/policereports.aspx'
req['User-Agent'] = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-us) AppleWebKit/533.17.8 (KHTML, like Gecko) Version/5.0.1 Safari/533.17.8'

Expand All @@ -25,6 +26,10 @@ def get_crime_data(type, start_date, end_date)
end

def crime_data_request(type, start_date, end_date)
# expected without leading zero
start_date.sub!(/^0/, '')
end_date.sub!(/^0/, '')

r = crime_request do |req|
req.url "/MNM/ajax/Crime,App_Web_uywmdsag.ashx?_method=GetCrimeData&_session=no"
req.body = "topleft=47.743825019093656, -122.43833543383
Expand Down

0 comments on commit 48eeb94

Please sign in to comment.