Skip to content
Permalink
master
Switch branches/tags

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?
Go to file
 
 
Cannot retrieve contributors at this time
#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