def search_places_for_location(location_id, limit: int = None, cursor=None): searcher = Facebook.PlaceSearcherForLocation(location_id) if cursor is not None: searcher.cursor = cursor places = {} while searcher.cursor is not False: found_places = searcher.next() for place in found_places: places[place.uid] = place.__dict__ if limit is not None and len(places) >= limit: break time.sleep(randint(3, 5)) return places, searcher.cursor