def city_search_parallel(city): """ Retrieves the JSON response that contains the top 20 business meta data for city. :param city: city name """ params = {'location': city, 'limit': 20} json_response = request(API_HOST, SEARCH_PATH, API_KEY, url_params=params) business_info_concurrent(json_response)
def city_search_parallel(city): """ Retrieves the JSON response that contains the top 20 business meta data for city. :param city: city name """ params = {'location': city, 'limit': 20} json_response = request(API_HOST, SEARCH_PATH, url_params=params) business_info_concurrent(json_response)
def city_search(city): """ Makes a request to Yelp's search API given the city name. :param city: :return: JSON meta data for top 20 businesses. """ params = {'location': city, 'limit': 20} json_response = request(API_HOST, SEARCH_PATH, url_params=params) return json_response
def business_info(business_id): """ Makes a request to Yelp's business API and retrieves the business data in JSON format. Dumps the JSON response into mongodb. :param business_id: """ business_path = BUSINESS_PATH + business_id response = request(API_HOST, business_path) coll.insert(response)
def scrape_business_info(business_id): """ Makes a request to Yelp's business API and retrieves the business data in JSON format. Dumps the JSON response into mongodb. :param business_id: """ business_path = BUSINESS_PATH + business_id response = request(API_HOST, business_path) coll.insert(response)
def city_search(location): """ Makes a request to Yelp's search API given the city name. :param city: :return: JSON meta data for top 20 businesses. """ url_params = { 'location': location.replace(' ', '+'), 'limit': SEARCH_LIMIT } return request(API_HOST, SEARCH_PATH, API_KEY, url_params=url_params)
def business_info(business_id): """ Makes a request to Yelp's business API and retrieves the business data in JSON format. Dumps the JSON response into mongodb. Creates a separate MongoClient instance for each thread. :param business_id: """ client = MongoClient() db = client[DB_NAME] coll = db[COLLECTION_NAME] business_path = BUSINESS_PATH + business_id response = request(API_HOST, business_path, API_KEY) coll.insert(response)