I have a .csv file of yelp reviews that I must use. It gives an alphanumeric id for each user and business(possibly review). I haven't been able to find any way of using these codes to locate the associated business' yelp page. The codes look like this...
"TR0-w6VoZDAdvFQiq7P2Ug" for Capriotti's Sandwich Shop
"pLZ9oZM8c6MNbRlg06lBPg" for Impact Auto Glass & Tint
etc...
I don't have any other info on these businesses that I could potentially use. I really want to be able to use Yelp's API to find image URLs (which I have been able to use), but haven't had any luck translating the info in my .csv file to something the API can use.
Thanks in advance.
Hey I wrote up this example, if you have an express server running you can paste in and try it out -
// 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');
});
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.