我有一个.csv文件的点评,我必须使用。它为每个用户和企业提供了一个字母数字id (可能是评论)。我还没有找到任何方法来使用这些代码来定位相关业务的yelp页面。代码是这样的..。
Capriotti's三明治店的“TR0-w6VoZDAdvFqq7P2Ug”
"pLZ9oZM8c6MNbRlg06lBPg“用于冲击汽车玻璃和着色
等等。
我没有任何关于这些业务的其他信息,我可能会使用。我真的希望能够使用Yelp的应用程序接口来查找图像URL(我已经能够使用它了),但是还没有将我的.csv文件中的信息转换成API可以使用的东西。
提前谢谢。
发布于 2018-03-18 02:44:00
嘿,我写了这个例子,如果你有一个正在运行的express服务器,你可以粘贴并试用它-
// 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');
});
})
https://stackoverflow.com/questions/49339252
复制相似问题