Skip to content

Instantly share code, notes, and snippets.

@Pinjasaur
Last active July 12, 2023 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pinjasaur/93f4a1d6f20086688e4d6a989d0543e5 to your computer and use it in GitHub Desktop.
Save Pinjasaur/93f4a1d6f20086688e4d6a989d0543e5 to your computer and use it in GitHub Desktop.
Minneapolis/St. Paul Restaurant Week programmatically get API endpoint
(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