Skip to content

Commit

Permalink
Scraper per morph.io
Browse files Browse the repository at this point in the history
  • Loading branch information
pierlauro committed Nov 9, 2015
1 parent 1cb1cb4 commit 257fae9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions requirements.txt
@@ -0,0 +1,2 @@
# pip install -r requirements.txt
scraperwiki>=0.3.2
8 changes: 5 additions & 3 deletions scraper.py
Expand Up @@ -2,6 +2,7 @@
import re
import requests
import json
import scraperwiki

def get_int( string ):
return int( re.search( r'\d+', string ).group() )
Expand All @@ -18,8 +19,9 @@ def get_int( string ):
station_data[ 'title' ] = station_split[ 0 ].split( ' - ', 1 )[ 1 ]
station_data[ 'available_bikes' ] = get_int( station_split[ 1 ] )
station_data[ 'available_electric_bikes' ] = get_int( station_split[ 2 ] )
station_data[ 'available_racks' ] = get_int( station_split[3] )
station_data[ 'position' ] = station[ 'position' ][ 'lat' ], station[ 'position' ][ 'lng' ]
station_data[ 'available_racks' ] = get_int( station_split[ 3 ] )
station_data[ 'latitude' ] = station[ 'position' ][ 'lat' ]
station_data[ 'longitude' ] = station[ 'position' ][ 'lng' ]
stations.append( station_data )

print json.dumps( stations )
scraperwiki.sqlite.save( unique_keys = [ 'id' ], data = stations )

0 comments on commit 257fae9

Please sign in to comment.