Skip to content

Instantly share code, notes, and snippets.

@vyashole
Last active September 22, 2024 10:43
Show Gist options
  • Save vyashole/8dbbd909943d96486857dfd5bb539ba2 to your computer and use it in GitHub Desktop.
Save vyashole/8dbbd909943d96486857dfd5bb539ba2 to your computer and use it in GitHub Desktop.
Gluttony - Zomato Order History Export
var results = []
$('.order-history-snippet').each(function() {
from = $(this).find('.col-l-16 .w100 .mtop0 .ui .item .content .header .left').text().trim()
status = $(this).find('.col-l-16 .w100 .mtop0 .ui .item .right b').text().trim()
orderNumber = $(this).find('.order-number').text().split(':')[1].trim()
cost = $(this).find('.cost b').text().trim().replace('₹', '') // comment the replace part if you want the ₹ symbol in the sheet.
//LibreOffice was having a hard time applying formulas to values with the symbol
date = $(this).find('.ui.basic.label').text().trim()
results.push({
date, orderNumber, from, cost, status
})
});
var fields = Object.keys(results[0])
var csv = results.map(function(row){
return fields.map(function(fieldName){
return JSON.stringify(row[fieldName])
}).join(',')
})
csv.unshift(fields.join(','))
text = csv.join('\r\n')
console.log(text)
var element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
element.setAttribute('download', 'export.csv');
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);

Gluttony

Zomato Order History Scraper

Usage

  • Log in to Zomato in your browser
  • Go to order hostory page
  • Click Load More as many times as you want. You can go back as far as you want. ( maybe I'll add this functionality in the script later)
  • Right click any item > Inspect
  • paste the contents of gluttony.js into the console and run it
  • You'll see a csv in your downloads when it's done.
@prateekkatyal
Copy link

prateekkatyal commented Sep 21, 2019

Super neat! 👍
Wanted to check how much money I've spent on orders :P

@Impactsince92
Copy link

Hey Adwait, I am doing a visualization project and need to use this code to export my order history. This code would help me so much by solving my problem, but i am facing issue while running it in console.
Getting the error:
Uncaught TypeError: Cannot read property 'each' of null

@vyashole
Copy link
Author

vyashole commented Aug 7, 2020

Hey, I don't think this script works anymore. It relied on the layout that zomato website used back in February 2019 lol.
The site has changed so much since then

@stonecharioteer
Copy link

Yep, this no longer works, instead you have a paginated view and most of the information is hidden in the cards.

@SouravDebnath09
Copy link

Let me work on it and fix this thing.

@sakethbolla
Copy link

Let me work on it and fix this thing.

So does it work now

@narengogi
Copy link

order history page has been removed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment