Created
December 6, 2012 03:31
-
-
Save mattneary/4221594 to your computer and use it in GitHub Desktop.
Fetch Jeopardy Titles
This file contains hidden or 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
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