Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Csv 如何按餐厅评级对餐厅名称列表进行排序(可能来自Google Places或Yelp Fusion API)_Csv_Sorting_Google Places Api_Yelp Fusion Api - Fatal编程技术网

Csv 如何按餐厅评级对餐厅名称列表进行排序(可能来自Google Places或Yelp Fusion API)

Csv 如何按餐厅评级对餐厅名称列表进行排序(可能来自Google Places或Yelp Fusion API),csv,sorting,google-places-api,yelp-fusion-api,Csv,Sorting,Google Places Api,Yelp Fusion Api,我有一个csv文件,其中包含数千个餐厅名称和地址,我需要按评级进行排序(csv中没有的数据)。有没有办法用这些数据填写csv?可能使用Google Places API或Yelp Fusion API?如果您查询业务名称和地址,Google Places API和Yelp Fusion API都可以让您获得餐厅的评级。我将解释如何做到这一点,但首先要注意法规遵从性。您所描述的内容显然违反了这两个API的服务条款。唯一允许使用的数据是在公开的网站或应用程序上显示。获取并将其保留在csv文件中显然是

我有一个csv文件,其中包含数千个餐厅名称和地址,我需要按评级进行排序(csv中没有的数据)。有没有办法用这些数据填写csv?可能使用Google Places API或Yelp Fusion API?

如果您查询业务名称和地址,Google Places API和Yelp Fusion API都可以让您获得餐厅的评级。我将解释如何做到这一点,但首先要注意法规遵从性。您所描述的内容显然违反了这两个API的服务条款。唯一允许使用的数据是在公开的网站或应用程序上显示。获取并将其保留在csv文件中显然是不合适的。这些API旨在为用户实时查询和即时显示结果

谷歌要求地点数据与谷歌地图或经批准的“由谷歌提供动力”图像一起显示。此外,不允许“预取、缓存或存储内容”。详情请参阅

Yelp需要归属,基本上要求您显示星级和Yelp徽标,并在Yelp上为您查询的餐厅显示返回业务页面的链接。此外,请参阅,您不能“在收到Yelp内容后的二十四(24)小时内缓存、记录、预取或以其他方式存储Yelp内容的任何部分,也不能尝试或提供执行任何刮削或“批量下载”操作的方法。”全文和术语请参阅

法律术语已不再适用,以下是如何从Google Places请求餐厅评级:

https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=Applebees,234 W 42nd St,New York,NY&inputtype=textquery&fields=formatted_address,name,rating&key=YOUR_API_KEY
JSON响应:

{
    "candidates": [
        {
            "formatted_address": "234 W 42nd St, New York, NY 10036, USA",
            "name": "Applebee's Grill + Bar",
            "rating": 3.6
        }
    ],
    "status": "OK"
}
{
    "businesses": [
        {
            "id": "gytFjzBw-z5LZD-6JSMChg",
            "alias": "applebees-grill-bar-new-york-3",
            "name": "Applebee's Grill + Bar",
            "image_url": "https://s3-media1.fl.yelpcdn.com/bphoto/CLizyj9S7pMvwGNm2dgdiQ/o.jpg",
            "is_closed": false,
            "url": "https://www.yelp.com/biz/applebees-grill-bar-new-york-3?adjust_creative=pnOv3Zj2REsNDMU4Z3-SLg&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=pnOv3Zj2REsNDMU4Z3-SLg",
            "review_count": 444,
            "categories": [
                {
                    "alias": "tradamerican",
                    "title": "American (Traditional)"
                },
                {
                    "alias": "burgers",
                    "title": "Burgers"
                },
                {
                    "alias": "sportsbars",
                    "title": "Sports Bars"
                }
            ],
            "rating": 2,
            "coordinates": {
                "latitude": 40.756442,
                "longitude": -73.988838
            },
            "transactions": [
                "delivery",
                "pickup"
            ],
            "price": "$$",
            "location": {
                "address1": "234 W 42nd St",
                "address2": "",
                "address3": "",
                "city": "New York",
                "zip_code": "10036",
                "country": "US",
                "state": "NY",
                "display_address": [
                    "234 W 42nd St",
                    "New York, NY 10036"
                ]
            },
            "phone": "+12123917414",
            "display_phone": "(212) 391-7414",
            "distance": 5.938732504864397
        }
    ],
    "total": 2900,
    "region": {
        "center": {
            "longitude": -73.98880004882812,
            "latitude": 40.75648701137637
        }
    }
}
这是对Yelp Fusion的相同请求。没有办法只要求评级。结果始终包含餐厅数据库中的所有内容:

https://api.yelp.com/v3/businesses/search?term=applebees&location=234 W 42nd St,New York,NY&limit=1
JSON响应:

{
    "candidates": [
        {
            "formatted_address": "234 W 42nd St, New York, NY 10036, USA",
            "name": "Applebee's Grill + Bar",
            "rating": 3.6
        }
    ],
    "status": "OK"
}
{
    "businesses": [
        {
            "id": "gytFjzBw-z5LZD-6JSMChg",
            "alias": "applebees-grill-bar-new-york-3",
            "name": "Applebee's Grill + Bar",
            "image_url": "https://s3-media1.fl.yelpcdn.com/bphoto/CLizyj9S7pMvwGNm2dgdiQ/o.jpg",
            "is_closed": false,
            "url": "https://www.yelp.com/biz/applebees-grill-bar-new-york-3?adjust_creative=pnOv3Zj2REsNDMU4Z3-SLg&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=pnOv3Zj2REsNDMU4Z3-SLg",
            "review_count": 444,
            "categories": [
                {
                    "alias": "tradamerican",
                    "title": "American (Traditional)"
                },
                {
                    "alias": "burgers",
                    "title": "Burgers"
                },
                {
                    "alias": "sportsbars",
                    "title": "Sports Bars"
                }
            ],
            "rating": 2,
            "coordinates": {
                "latitude": 40.756442,
                "longitude": -73.988838
            },
            "transactions": [
                "delivery",
                "pickup"
            ],
            "price": "$$",
            "location": {
                "address1": "234 W 42nd St",
                "address2": "",
                "address3": "",
                "city": "New York",
                "zip_code": "10036",
                "country": "US",
                "state": "NY",
                "display_address": [
                    "234 W 42nd St",
                    "New York, NY 10036"
                ]
            },
            "phone": "+12123917414",
            "display_phone": "(212) 391-7414",
            "distance": 5.938732504864397
        }
    ],
    "total": 2900,
    "region": {
        "center": {
            "longitude": -73.98880004882812,
            "latitude": 40.75648701137637
        }
    }
}

Google Places API和Yelp Fusion API都可以让您在查询企业名称和地址时获得餐厅的评级。我将解释如何做到这一点,但首先要注意法规遵从性。您所描述的内容显然违反了这两个API的服务条款。唯一允许使用的数据是在公开的网站或应用程序上显示。获取并将其保留在csv文件中显然是不合适的。这些API旨在为用户实时查询和即时显示结果

谷歌要求地点数据与谷歌地图或经批准的“由谷歌提供动力”图像一起显示。此外,不允许“预取、缓存或存储内容”。详情请参阅

Yelp需要归属,基本上要求您显示星级和Yelp徽标,并在Yelp上为您查询的餐厅显示返回业务页面的链接。此外,请参阅,您不能“在收到Yelp内容后的二十四(24)小时内缓存、记录、预取或以其他方式存储Yelp内容的任何部分,也不能尝试或提供执行任何刮削或“批量下载”操作的方法。”全文和术语请参阅

法律术语已不再适用,以下是如何从Google Places请求餐厅评级:

https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=Applebees,234 W 42nd St,New York,NY&inputtype=textquery&fields=formatted_address,name,rating&key=YOUR_API_KEY
JSON响应:

{
    "candidates": [
        {
            "formatted_address": "234 W 42nd St, New York, NY 10036, USA",
            "name": "Applebee's Grill + Bar",
            "rating": 3.6
        }
    ],
    "status": "OK"
}
{
    "businesses": [
        {
            "id": "gytFjzBw-z5LZD-6JSMChg",
            "alias": "applebees-grill-bar-new-york-3",
            "name": "Applebee's Grill + Bar",
            "image_url": "https://s3-media1.fl.yelpcdn.com/bphoto/CLizyj9S7pMvwGNm2dgdiQ/o.jpg",
            "is_closed": false,
            "url": "https://www.yelp.com/biz/applebees-grill-bar-new-york-3?adjust_creative=pnOv3Zj2REsNDMU4Z3-SLg&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=pnOv3Zj2REsNDMU4Z3-SLg",
            "review_count": 444,
            "categories": [
                {
                    "alias": "tradamerican",
                    "title": "American (Traditional)"
                },
                {
                    "alias": "burgers",
                    "title": "Burgers"
                },
                {
                    "alias": "sportsbars",
                    "title": "Sports Bars"
                }
            ],
            "rating": 2,
            "coordinates": {
                "latitude": 40.756442,
                "longitude": -73.988838
            },
            "transactions": [
                "delivery",
                "pickup"
            ],
            "price": "$$",
            "location": {
                "address1": "234 W 42nd St",
                "address2": "",
                "address3": "",
                "city": "New York",
                "zip_code": "10036",
                "country": "US",
                "state": "NY",
                "display_address": [
                    "234 W 42nd St",
                    "New York, NY 10036"
                ]
            },
            "phone": "+12123917414",
            "display_phone": "(212) 391-7414",
            "distance": 5.938732504864397
        }
    ],
    "total": 2900,
    "region": {
        "center": {
            "longitude": -73.98880004882812,
            "latitude": 40.75648701137637
        }
    }
}
这是对Yelp Fusion的相同请求。没有办法只要求评级。结果始终包含餐厅数据库中的所有内容:

https://api.yelp.com/v3/businesses/search?term=applebees&location=234 W 42nd St,New York,NY&limit=1
JSON响应:

{
    "candidates": [
        {
            "formatted_address": "234 W 42nd St, New York, NY 10036, USA",
            "name": "Applebee's Grill + Bar",
            "rating": 3.6
        }
    ],
    "status": "OK"
}
{
    "businesses": [
        {
            "id": "gytFjzBw-z5LZD-6JSMChg",
            "alias": "applebees-grill-bar-new-york-3",
            "name": "Applebee's Grill + Bar",
            "image_url": "https://s3-media1.fl.yelpcdn.com/bphoto/CLizyj9S7pMvwGNm2dgdiQ/o.jpg",
            "is_closed": false,
            "url": "https://www.yelp.com/biz/applebees-grill-bar-new-york-3?adjust_creative=pnOv3Zj2REsNDMU4Z3-SLg&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=pnOv3Zj2REsNDMU4Z3-SLg",
            "review_count": 444,
            "categories": [
                {
                    "alias": "tradamerican",
                    "title": "American (Traditional)"
                },
                {
                    "alias": "burgers",
                    "title": "Burgers"
                },
                {
                    "alias": "sportsbars",
                    "title": "Sports Bars"
                }
            ],
            "rating": 2,
            "coordinates": {
                "latitude": 40.756442,
                "longitude": -73.988838
            },
            "transactions": [
                "delivery",
                "pickup"
            ],
            "price": "$$",
            "location": {
                "address1": "234 W 42nd St",
                "address2": "",
                "address3": "",
                "city": "New York",
                "zip_code": "10036",
                "country": "US",
                "state": "NY",
                "display_address": [
                    "234 W 42nd St",
                    "New York, NY 10036"
                ]
            },
            "phone": "+12123917414",
            "display_phone": "(212) 391-7414",
            "distance": 5.938732504864397
        }
    ],
    "total": 2900,
    "region": {
        "center": {
            "longitude": -73.98880004882812,
            "latitude": 40.75648701137637
        }
    }
}

请告诉我们你已经做了什么,这样我们才能帮助你。请告诉我们你已经做了什么,这样我们才能帮助你。