带有 Yelp API 的 Yelp 企业 ID 代码



我有一个.csv的yelp评论文件,我必须使用。它为每个用户和企业(可能是评论(提供一个字母数字ID。我无法找到使用这些代码来查找相关业务的yelp页面的任何方法。代码看起来像这样...

"TR0-w6VoZDAdvFQiq7P2Ug"为Capriotti的三明治店

"pLZ9oZM8c6MNbRlg06lBPg" for Impact Auto Glass & Tint

等。。。

我没有关于这些业务的任何其他信息,我可能会使用。我真的很希望能够使用 Yelp 的 API 来查找图像 URL(我已经能够使用(,但没有任何运气将我的 .csv 文件中的信息转换为 API 可以使用的内容。

提前谢谢。

嘿,

我写了这个例子,如果你有一个正在运行的快速服务器,你可以粘贴并尝试一下 -

// using express
// client - refers to yelp-fusion.client - checkout yelp-fusion NPM
app.get('/reviews', (req, res) => {
  let id = 'TR0-w6VoZDAdvFQiq7P2Ug';
  // id example from your Comment
  client.reviews(id).then(response => {
    // find review from ID given in CSV File:
    let url = new URL(response.jsonBody.reviews[0].url);
    // parse URL using url-parse package, return just pathname
    let bizName = url.pathname.substring(5,url.pathname.length);
    // every yelp pathname begins with /biz/ - use substring to return only biz name
    // now use that bizName to look up business - which will have image url within response:
    client.business(bizName)
    .then(response => {
      console.log(response.jsonBody);
      let featuredImgUrl = response.jsonBody.image_url;
      let photos = response.jsonBody.photos;
      res.json(photos)
    });
  }).catch(e => {
    console.log(e);
    res.json('Error');
  });
})

最新更新