Skip to content

Instantly share code, notes, and snippets.

@charlesponti
Last active February 4, 2025 01:06
Show Gist options
  • Save charlesponti/64a0c6b2d8e276a46eafca5c908610e3 to your computer and use it in GitHub Desktop.
Save charlesponti/64a0c6b2d8e276a46eafca5c908610e3 to your computer and use it in GitHub Desktop.
script to scrape uber eats orders
{
"total": 1194.5500000000002,
"restaurants": {
"sweetgreen": {
"visits": 3,
"total": 185.93
},
"Pine and Crane": {
"visits": 3,
"total": 258.31
},
"Tocaya Organica": {
"visits": 1,
"total": 57.99
},
"McDonald's®": {
"visits": 1,
"total": 41.66
},
"Mendocino Farms": {
"visits": 3,
"total": 146.01
},
"Tender Greens Hollywood": {
"visits": 1,
"total": 38.99
},
"Wendy's": {
"visits": 1,
"total": 33.49
},
"Freebirds World Burrito": {
"visits": 1,
"total": 22.07
},
"Pizzana": {
"visits": 2,
"total": 162.98000000000002
},
"Sticky Rice": {
"visits": 1,
"total": 103.85
},
"Jack in the Box": {
"visits": 1,
"total": 53.64
},
"Lemon Poppy Kitchen": {
"visits": 1,
"total": 89.63
}
},
"orders": [
{
"restaurant": "sweetgreen",
"numOfItems": 3,
"price": "$58.86",
"date": "Jan 28 at 6:31 PM"
},
{
"restaurant": "Pine and Crane",
"numOfItems": 6,
"price": "$78.35",
"date": "Jan 17 at 7:09 PM"
},
{
"restaurant": "Tocaya Organica",
"numOfItems": 3,
"price": "$57.99",
"date": "Jan 09 at 6:48 PM"
},
{
"restaurant": "McDonald's®",
"numOfItems": 4,
"price": "$41.66",
"date": "Dec 11 at 7:51 PM"
},
{
"restaurant": "Mendocino Farms",
"numOfItems": 3,
"price": "$47.72",
"date": "Nov 12 at 6:23 PM"
},
{
"restaurant": "sweetgreen",
"numOfItems": 4,
"price": "$67.32",
"date": "Oct 19 at 6:42 PM"
},
{
"restaurant": "sweetgreen",
"numOfItems": 3,
"price": "$59.75",
"date": "Aug 31 at 6:11 PM"
},
{
"restaurant": "Tender Greens Hollywood",
"numOfItems": 3,
"price": "$38.99",
"date": "Apr 24 at 2:34 PM"
},
{
"restaurant": "Wendy's",
"numOfItems": 2,
"price": "$33.49",
"date": "Jan 28 at 4:08 PM"
},
{
"restaurant": "Freebirds World Burrito",
"numOfItems": 2,
"price": "$22.07",
"date": "Jan 21 at 5:40 PM"
},
{
"restaurant": "Pizzana",
"numOfItems": 2,
"price": "$71.26",
"date": "Jan 05 at 6:38 PM"
},
{
"restaurant": "Pine and Crane",
"numOfItems": 8,
"price": "$92.93",
"date": "Dec 15 at 7:21 PM"
},
{
"restaurant": "Mendocino Farms",
"numOfItems": 3,
"price": "$40.67",
"date": "Oct 17 at 8:06 PM"
},
{
"restaurant": "Mendocino Farms",
"numOfItems": 3,
"price": "$57.62",
"date": "Jul 14 at 6:57 PM"
},
{
"restaurant": "Sticky Rice",
"numOfItems": 4,
"price": "$103.85",
"date": "May 12 at 7:15 PM"
},
{
"restaurant": "Jack in the Box",
"numOfItems": 3,
"price": "$53.64",
"date": "Apr 24 at 6:14 PM"
},
{
"restaurant": "Pine and Crane",
"numOfItems": 8,
"price": "$87.03",
"date": "Apr 14 at 7:47 PM"
},
{
"restaurant": "Pizzana",
"numOfItems": 3,
"price": "$91.72",
"date": "Mar 24 at 7:29 PM"
},
{
"restaurant": "Lemon Poppy Kitchen",
"numOfItems": 4,
"price": "$89.63",
"date": "Mar 11 at 6:48 PM"
}
]
}
const result = {
// Total amount spent on Uber Eats
total: 0,
// Per-restaurant info
restaurants: {},
// The order informations
orders: []
}
orders.forEach((o) => {
const node = Array.from(o.querySelectorAll('.ls'))
let info = node[1]
.textContent
.split("•").map(s => s.trim()).slice(0, 2)
const rest = (
Array
.from(o.querySelectorAll('a[data-baseweb="link"]'))
.filter(o => o.href.indexOf("/store") >= 0)[0]
.textContent
)
let itemsAndPrice = info[0].split(" items for ")
let numOfItems = Number(itemsAndPrice[0])
let price = parseFloat(itemsAndPrice[1].slice(1))
// 1. Add price to result total
result.total += price
// 2. Add or update the restaurant
if (result.restaurants[rest]) {
result.restaurants[rest].visits += 1
result.restaurants[rest].total += price
} else {
result.restaurants[rest] = { visits: 1, total: price }
}
// 3. Add order to the orders
result.orders.push({
restaurant: rest,
numOfItems,
price: itemsAndPrice[1],
date: info[1],
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment