Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
ChatBot_A6/YELP.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
24 lines (19 sloc)
1.33 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#This module was written primarily by Vinayak Sareen and edited slightly by Humza Shahid for GUI integration. | |
#To see Vinayak's original work, compare this file with the other YELP.py in this repository. This YELP.py contains Humza's changes. | |
from yelpapi import YelpAPI | |
from Locator import * | |
def yelpSearch(Search_Title, yelpIndex): | |
yelp_api = YelpAPI("D3YORn8vNBNb6WMLGRMOZA", | |
"aLApXFhKxXVEcU5PZbDFfzseDAJWmcjZ9g78YUB4dLfFyxksNsEKAiRTQLnoVB2k") | |
# Searching Api | |
# https://www.yelp.com/developers/documentation/v3/business_search | |
Search_City, Search_Country = userLocator() | |
Search_Location = Search_City +", " +Search_Country | |
response = yelp_api.search_query(term= Search_Title, location= Search_Location , sort_by='rating') | |
try: | |
Search_ID_Name = response["businesses"][yelpIndex]["id"] #yelpIndex variable fetches data from list (for example, if user searched for one location, then yelpIndex increases by one so next location is retrieved | |
Rating = response["businesses"][yelpIndex]["rating"] | |
except IndexError: #if the API does not have an area at this index, it will throw an error at this index, so return a different value in this case. | |
Search_ID_Name = "Chatbot: We are sorry, but we cannot find any more stores matching this criteria.\n" | |
Rating = "" | |
return Search_ID_Name, Rating |