Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mager/469745 to your computer and use it in GitHub Desktop.
Save mager/469745 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import simplegeo
import time
import feedparser
from simplegeo import Client, Record, APIError
MY_OAUTH_KEY = '[insert_your_oauth_key_here]'
MY_OAUTH_SECRET = '[insert_your_oauth_secret_here]'
MY_LAYER = 'com.foursquare.[insert_foursquare_username].checkins'
records = []
def main():
client = Client(MY_OAUTH_KEY, MY_OAUTH_SECRET)
d = feedparser.parse('[insert_your_foursquare_rss_feed_here]')
for item in d['items']:
if 'point' in item:
coords = item['point'].split()
lat = coords[0]
lon = coords[1]
record = Record(
layer=MY_LAYER,
id=item['guid'],
lat=lat,
lon=lon,
created=int(time.mktime(item['updated_parsed'])),
name=item['title'],
venue_link=item['links'][0]['href']
)
records.append(record)
print(records)
for chunk in chunker(records, 90):
client.add_records(MY_LAYER, chunk)
print "%s records added" % len(chunk)
def chunker(seq, size):
return (seq[pos:pos + size] for pos in xrange(0, len(seq), size))
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment