Skip to content

Instantly share code, notes, and snippets.

@mseeley
Created August 21, 2017 08:12
Show Gist options
  • Save mseeley/d7b5c24f950a31e6370766d2ef856178 to your computer and use it in GitHub Desktop.
Save mseeley/d7b5c24f950a31e6370766d2ef856178 to your computer and use it in GitHub Desktop.
USA Amiibo line-up scraper

Use the script below to quickly scrap structured data from the USA Nintendo Amiibo Line-Up: http://www.nintendo.com/amiibo/line-up.

After running this code in the Web Insector Console tab, in Chrome, the serialized JSON will be waiting patiently in your paste buffer.

copy(Array.from(document.querySelectorAll('a[data-index]')).map((a) => {
  const gameID = a.parentNode.dataset.gameId;
  const relatedTo = a.querySelector('[itemprop=isRelatedTo]');
  const spans = Array.from(a.querySelectorAll('span'));
  const offset = /coming-soon-badge/.test(spans[spans.length - 1].className) ? -2 : -1;
  const availableElement = spans[spans.length + offset];

  return {
    gameID,
    href: a.href,
    name: a.querySelector('[itemprop=name]').textContent,
    image: a.querySelector('[itemprop=image]').src,
    relatedTo: relatedTo && relatedTo.textContent,
    available: availableElement.textContent.replace(/Available |[\n\t]/g, '')
  };
}));
@mseeley
Copy link
Author

mseeley commented Aug 21, 2017

Sample output as of 2017/08/20:

[
  {
    "gameID": "TdeA-E5smAJkIq_QBc2m1LWN3N3P6Bmu",
    "href": "http://www.nintendo.com/amiibo/detail/tiki-amiibo-fire-emblem-series",
    "name": "Tiki",
    "image": "http://media.nintendo.com/nintendo/bin/wm8gQSjQ38OoKWZ8Lk6Dari4o6Kf2zWt/i1aJpXUrnP4_bDx5WTqsTzi9jHvYCLyh.png",
    "relatedTo": "Fire Emblem series",
    "available": "TBD"
  },
  ...

@mseeley
Copy link
Author

mseeley commented Aug 21, 2017

http://nintendo.wikia.com/wiki/List_of_amiibo has larger resolution artwork if you're brave. The markup isn't structured uniformly enough for easy scraping.

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