Skip to content

Instantly share code, notes, and snippets.

@mattneary
Created December 6, 2012 03:31
Show Gist options
  • Save mattneary/4221594 to your computer and use it in GitHub Desktop.
Save mattneary/4221594 to your computer and use it in GitHub Desktop.
Fetch Jeopardy Titles
var http = require('http'),
fs = require('fs');
var fetchShow = function(code) {
http.get({
host: "www.j-archive.com",
port: 80,
path: "/showgame.php?game_id="+code
}, function(response) {
var buffer = [];
response.on("data", function(chunk) {
buffer.push(chunk);
});
response.on("end", function() {
var matches = buffer.join("").match(/<tr>.*<\/tr>/g);
if( !matches ) return;
var groups = matches.filter(function(t){return -1!=t.indexOf("category_name")}).map(function(t){return t.replace(/<[^>]+>/g,'')});
console.log(code);
fs.open(__dirname+'/out2.txt', 'a', 666, function( e, id ) {
fs.write( id, groups.join("\n")+"\n", null, 'utf8', function(){
fs.close(id, function(){});
});
});
});
});
};
for( var i = 200; i < 3049; i++ ) fetchShow(i);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment