コード例 #1
0
class ZomotoAPI:
    def __init__(self):

        # Api secret keys stored in enviornment variable

        self.api_key = os.environ.get('api_key')

    def get_Categories(self, citi_id):

        self.api_client_auth = Pyzomato(self.api_key)

        self.api_client_auth.search(name="Chennai")

        # city id for chennai is 7

        return self.api_client_auth.getCategories()

    def search_city_by_geo_code(self, latitude, longitude):

        return self.api_client_auth.getByGeocode(latitude, longitude)

    def locating_res_by_id(self, res_id):

        # id > 18387708
        # name > kakada ramprasad
        # "locality_verbose": "Kilpauk, Chennai"

        return self.api_client_auth.getRestaurantDetails(res_id)
コード例 #2
0
def showRestaurantDetails(request, value):
	p = Pyzomato('ca5cbda00917434b4886bcf7fcc01b97')
	restDetails = p.getRestaurantDetails(value)
	id = value
	name=restDetails["name"]
	url=restDetails["url"]
	address=restDetails['location']['address']
	cuisines=restDetails['cuisines']
	average_cost_for_two=restDetails['average_cost_for_two']
	thumbnail=restDetails['thumb']
	rating=restDetails['user_rating']['aggregate_rating']
	popular_opinion=restDetails['user_rating']['rating_text']
	votes=restDetails['user_rating']['votes']
	photos=restDetails['photos_url']
	menu=restDetails['menu_url']
	featured_image=restDetails['featured_image']
	details = [dict() for x in range(12)]
	details = {'id':id, 'name':name, 'name':name, 'address':address, 'average_cost_for_two':average_cost_for_two,'featured_image':featured_image, 
	'thumbnail':thumbnail, 'rating':rating, 'popular_opinion':popular_opinion, 'photos':photos, 'menu':menu,'cuisines': cuisines,'votes':votes}
	request.session[0]=value
	request.session[1]=details
	all_enties = RestaurantReview.objects.all().filter(restaurantId=value)
	reviewList = []
	for p in all_enties:
		reviewElement = [dict() for x in range(9)]
		review = p.review
		rating = p.rating
		userName = p.user
		reviewElement={'review':review,'rating':rating, 'userName':userName}
		reviewList.append(reviewElement)
	return render(request, 'restaurantview.html', {'restdetails':details, 'reviewsAndRatings':reviewList})
コード例 #3
0
        ) + "/user?count=0&apikey=a54e351eb6f630cb9ed6f8efe31e0c1e"
        req = urllib2.Request(url)
        restt = urllib2.urlopen(req)

        json_data = json.load(restt)
        review_count = json_data['reviewsCount']
        #get restaurant details using restaurant id
        url_det = "https://api.zomato.com/v1/restaurant.json/" + str(
            restaurant_id) + "?apikey=a54e351eb6f630cb9ed6f8efe31e0c1e"
        requesting = urllib2.Request(url_det)
        results_rest = urllib2.urlopen(requesting)
        json_dat = json.load(results_rest)
        link = json_dat['userReviews']['review_url']
        name = json_dat['name']
        address = json_dat['location']['address']
        debt = p.getRestaurantDetails(restaurant_id)
        #get image icon of restaurant id
        image = debt['thumb']
        user_rating = debt['user_rating']['aggregate_rating']
        if review_count == 0:
            pass
        else:
            revjjsjs = json_data['userReviews']
            for i in revjjsjs:
                m = i['review']
                t = m['reviewText']
                t = t.encode('unicode-escape')
                txt = t

                if (txt != None):
                    blob = TextBlob(txt)
コード例 #4
0
ファイル: views.py プロジェクト: duguarun/RestaurantSearch
def searchRestaurant(request):
    p = Pyzomato('c5515b949415a90fe3c9dfebf2d1b246')
    if request.GET.get('city', False) or request.GET.get('search', False):
        city = request.GET["city"]
        search_key = request.GET["search"]

        city = p.getLocations("query=" + str(city))
        res_id = []
        data = {}

        search_results = p.search(
            entity_id=city['location_suggestions'][0]['entity_id'],
            entity_type=city['location_suggestions'][0]['entity_type'],
            q=search_key)
        # print(search_results['restaurants'][0]['restaurant']['R']['res_id'],search_results['restaurants'][1]['restaurant']['R']['res_id'])
        # search_results = p.search(entity_id=city['location_suggestions'][id]['entity_id'], entity_type=city['location_suggestions'][id]['entity_type'] ,q=search_key)
        try:
            for id in range(0, 10):
                resta_id = search_results['restaurants'][id]['restaurant'][
                    'R']['res_id']
                data[resta_id] = {}
                data[resta_id]['name'] = search_results['restaurants'][id][
                    'restaurant']['name']
                data[resta_id]['cusine'] = search_results['restaurants'][id][
                    'restaurant']['cuisines']
                data[resta_id]['address'] = search_results['restaurants'][id][
                    'restaurant']['location']['address']
                data[resta_id]['average_cost_for_two'] = search_results[
                    'restaurants'][id]['restaurant']['average_cost_for_two']
                data[resta_id]['rating'] = search_results['restaurants'][id][
                    'restaurant']['user_rating']['aggregate_rating']
                res_id.append(resta_id)
        except:
            status = 'failed'
        else:
            status = 'success'
        if status == 'success':
            return render(
                request, 'Restaurant_Search/SearchResults.html', {
                    'res_id': res_id,
                    'data': data,
                    'city': request.GET["city"],
                    'search_key': search_key
                })
        if status == 'failed':
            return render(
                request, 'Restaurant_Search/SearchResults.html', {
                    'res_id': res_id,
                    'data': data,
                    'city': request.GET["city"],
                    'search_key': search_key,
                    'no_results': 'no_results'
                })

    elif request.GET.get('res_id', False):
        res_id = request.GET["res_id"]
        data = p.getRestaurantDetails(restaurant_id=res_id)

        print(data['name'])
        data
        return JsonResponse(data)
コード例 #5
0
import pprint
from pyzomato import Pyzomato
pp = pprint.PrettyPrinter(indent=2)

p = Pyzomato("aa2e170fced5e4de42b96789a76fbd7f")
p.search(q="las vegas")

categories = p.getCategories()
pp.pprint( categories )

dets = p.getCollectionsViaCityId(282)
pp.pprint( dets )

cus = p.getCuisines(282)
pp.pprint( cus )

estab = p.getEstablishments(282)
pp.pprint( estab )

#need resturant ID
menu = p.getDailyMenu(292)
pp.pprint( menu )

#need resturant ID
info = p.getRestaurantDetails(292)
pp.pprint( info )

#need resturant ID
reviews = p.getRestaurantReviews(291)
pp.pprint( reviews )