McDonald Menu
by RFour · Jul 10, 2026 ·javascript
Basically get details and stuff from indonesia McDonalds menu list, idc what you're going to use this for because this is practically useless
McdMcDonald's
| 1 | const axios = require('axios'); |
| 2 | const cheerio = require('cheerio'); |
| 3 | |
| 4 | async function listMenu() { |
| 5 | const url = 'https://www.mcdonalds.co.id/menu'; |
| 6 | const headers = { 'User-Agent': 'Mozilla/5.0' }; |
| 7 | const res = await axios.get(url, { headers }); |
| 8 | const $ = cheerio.load(res.data); |
| 9 | const menus = []; |
| 10 | $('section.section-menu-list').each((_, section) => { |
| 11 | const cat = $(section).attr('id') || 'Unknown'; |
| 12 | $(section).find('a.card-menu').each((_, card) => { |
| 13 | const name = $(card).find('p').text().trim(); |
| 14 | if (name) { |
| 15 | menus.push({ |
| 16 | name: name, |
| 17 | category: cat, |
| 18 | image: $(card).find('img').attr('src'), |
| 19 | url: $(card).attr('href') |
| 20 | }); |
| 21 | } |
| 22 | }); |
| 23 | }); |
| 24 | return menus; |
| 25 | } |
| 26 | |
| 27 | async function searchMenu(category) { |
| 28 | const url = 'https://www.mcdonalds.co.id/menu'; |
| 29 | const headers = { 'User-Agent': 'Mozilla/5.0' }; |
| 30 | const res = await axios.get(url, { headers }); |
| 31 | const $ = cheerio.load(res.data); |
| 32 | const results = []; |
| 33 | $('section.section-menu-list').each((_, section) => { |
| 34 | if ($(section).attr('id') === category) { |
| 35 | $(section).find('a.card-menu').each((_, card) => { |
| 36 | const name = $(card).find('p').text().trim(); |
| 37 | if (name) { |
| 38 | results.push({ |
| 39 | name: name, |
| 40 | image: $(card).find('img').attr('src'), |
| 41 | url: $(card).attr('href') |
| 42 | }); |
| 43 | } |
| 44 | }); |
| 45 | } |
| 46 | }); |
| 47 | return results; |
| 48 | } |
| 49 | |
| 50 | async function detailMenu(url) { |
| 51 | const headers = { 'User-Agent': 'Mozilla/5.0' }; |
| 52 | const res = await axios.get(url, { headers }); |
| 53 | const $ = cheerio.load(res.data); |
| 54 | const title = $('h2.title').first().text().trim() || null; |
| 55 | const desc = $('p.subtitle').first().text().trim() || null; |
| 56 | const image = $('img.img-fluid.animated.vp-slideinleft.delayp3').first().attr('src') || null; |
| 57 | const nutrition = {}; |
| 58 | const fat = $('.nutrition_weight-value-fat').data('val'); |
| 59 | if (fat) nutrition.fat = parseFloat(fat); |
| 60 | const protein = $('.nutrition_weight-value-protein').data('val'); |
| 61 | if (protein) nutrition.protein = parseFloat(protein); |
| 62 | const carbs = $('.nutrition_weight-value-karbohidrat').data('val'); |
| 63 | if (carbs) nutrition.carbs = parseFloat(carbs); |
| 64 | const energy = $('.nutrition_weight-value-energy').data('val'); |
| 65 | if (energy) nutrition.energy = parseFloat(energy); |
| 66 | if (Object.keys(nutrition).length === 0) { |
| 67 | nutrition.available = false; |
| 68 | } else { |
| 69 | nutrition.available = true; |
| 70 | } |
| 71 | return { title, desc, image, nutrition, url }; |
| 72 | } |
| 73 | |
| 74 | listMenu().then(data => console.log(JSON.stringify(data, null, 2))); |
| 75 | searchMenu('Sarapan Pagi').then(data => console.log(JSON.stringify(data, null, 2))); |
| 76 | detailMenu('https://www.mcdonalds.co.id/menu/chicken-muffin').then(data => console.log(JSON.stringify(data, null, 2))); |