Last active
July 12, 2023 16:46
-
-
Save Pinjasaur/93f4a1d6f20086688e4d6a989d0543e5 to your computer and use it in GitHub Desktop.
Minneapolis/St. Paul Restaurant Week programmatically get API endpoint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(async () => { | |
const res = await fetch('https://mspmag.com/promotions/restaurantweek') | |
const html = await res.text() | |
const parser = new DOMParser() | |
const doc = parser.parseFromString(html, 'text/html'); | |
const $scripts = Array.from(doc.querySelectorAll('script')) | |
const $script = $scripts.filter($script => $script.innerHTML.trim().startsWith('var _mp_require = {')).pop() | |
const json = JSON.parse($script.innerHTML.trim().replace(/^var _mp_require =/, '').replace(/;$/, '')) | |
console.log(json['config']['js/page_roundup_location']['locations_url']) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment