Skip to content

Instantly share code, notes, and snippets.

@mfrancois3k
Forked from JRHeaton/yugiohlist.js
Created May 30, 2024 16:32
Show Gist options
  • Save mfrancois3k/f3f25a7a669d8f3d501d93ac5fa8c763 to your computer and use it in GitHub Desktop.
Save mfrancois3k/f3f25a7a669d8f3d501d93ac5fa8c763 to your computer and use it in GitHub Desktop.
Scrapes the current forbidden/limited list for Yu-Gi-Oh! cards and converts it to JSON.
var _ = require('underscore')
var cheerio = require('cheerio')
var request = require('request')
var println = console.log
request('http://www.yugioh-card.com/en/limited/', function (err, res, body) {
var $ = cheerio.load(body)
var cards = []
$('#colfull_main table tr').each(function (i, elem) {
var data = $(elem).children('td')
.map(function (ii, e) {
return $(e).text()
})
.get()
cards.push({
"type" : data[0],
"name" : data[1].replace(/\s+/g, ' '),
"status" : data[2],
"comment" : data[3]
})
})
println(JSON.stringify(cards, null, '\t'))
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment