Using this script on any browser, you can sort the restaurants listed in the foodpanda website by rating or review count.
- Visit foodpanda.com and select your location.
- Keep scrolling down to the bottom of the page until all resaurants are loaded on the page.
- In Chrome, right click anywhere on the page and select Inspect from the menu.
- In the Inspect window click the Console tab.
- In the console, paste in the following script and hit enter.
var name, ratingElement, rating, categories, cats, deliveryTime, budget, count;
var pattern = /(.*?)\/5 \((.*?)\)/i;
var thousandPattern = /(.*?)k\+/i;
var restaurants = []
var rs = document.getElementsByClassName("vendor-tile");
for (var i = 0; i < rs.length; i++) {
// Name.
name = rs.item(i).getElementsByClassName('name').item(0).textContent;
// Categories.
cats = rs.item(i).getElementsByClassName('vendor-characteristic').item(0);
cats = cats.getElementsByTagName('span');
categories = [];
for (var j = 0; j < cats.length; j++) {
categories.push(cats.item(j).textContent);
}
// Rating and review count.
ratingElement = rs.item(i).getElementsByClassName('ratings-component').item(0);
rating = 0
count = 0
if (ratingElement != null) {
rating = parseFloat(ratingElement.textContent.match(pattern)[1]);
count = ratingElement.textContent.match(pattern)[2];
if (!isNaN(count)) {
count = parseInt(count);
}
else {
count = parseInt(count.match(thousandPattern)[1]) * 1000;
}
}
// Delivery time.
deliveryTime = rs.item(i).getElementsByClassName('badge-info').item(0).textContent;
// Budget.
budget = rs.item(i).getElementsByClassName('budget-symbol--filled');
budget = budget.length + "/3";
restaurants.push({
name: name,
rating: rating,
count: count,
categories: categories.toString(),
delivery_time: deliveryTime,
budget: budget
});
}
// Remove duplicates.
restaurants = restaurants.filter((v,i,a) => a.findIndex(t => (t.name === v.name && t.count === v.count))===i)
console.table(restaurants);
- You will be presented with a table of restaurants. Now click on rating or count column name to sort by ascending or descending order.