Foursquare give us api to get this information
But the raw data is not perfect json object when I use Java to do this work.
I apply python to do this work. The code is more simple and perfect.
The code is fellow:
import urllib2
import json
import pymongo
import sys, os, stat
from pymongo import Connection
c = Connection('localhost', 27017)
db = c.FourS2
finf = db.FourInformation
fpho = db.FourPhotos
ftip = db.FourTips
VenueList = db.Venuelist
for item in VenueList.find():
venueid = item['_id']
url1 = 'https://api.foursquare.com/v2/venues/'
url2 = '?client_id=HD0ZXRNBOA4XPJWZOKU1IQMN12AJAKWNFELCD10FSLYGHYMT&client_secret=DQLZUI0M0SXTQTPR4DMMZYTZHE45GISJBNOR4MMWO3V4R41L'
request = url1+venueid+url2
content = urllib2.urlopen(request).read()
temp = json.loads(content)
lat = temp['response']['venue']['location']['lat']
lng = temp['response']['venue']['location']['lng']
item['lat'] = lat
item['lng'] = lng
VenueList.save(item)
we apply package json to convert the raw data into json object.
Finally, we save this data into Mongodb.