Created
October 3, 2011 09:06
-
-
Save ydnax/1258745 to your computer and use it in GitHub Desktop.
humble keycrawler.
This file contains 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 urllib=require("./urllib.js"); | |
var sys=require("sys"); | |
var urlparser=require("url"); | |
var spawn = require('child_process').spawn; | |
var starturl="http://www.google.com/search?hl=en&q=http%3A%2F%2Fwww.humblebundle.com%2F%3Fkey%3D"; | |
var regex=/www ?\. ?humblebundle ?\. ?com ?\/\?key ?\=\w{2,13}/ig; | |
var hit=function(url){ | |
//console.log("newurl: "+url); | |
try{ | |
urllib.processUrl(url, function($){ | |
var m; | |
try{ | |
m=regex.exec($("html").html()); | |
}catch(e){} | |
if(!m){ | |
//console.log("nohit: "+url); | |
return; | |
} | |
m.input=""; | |
//console.log("hit: "+url); | |
//console.log(sys.inspect(m)); | |
console.log(m[0]); | |
spawn('firefox', [m[0]]); | |
});}catch(e){console.log("error url:"+url);}; | |
}; | |
var searchPage=function(url){ | |
//console.log("nexturl"+url);https://gist | |
urllib.processUrl(url, | |
function($){ | |
$(".r").each(function(){ | |
hit($("a",this).attr("href")); | |
});//pnnext | |
try{ | |
var purl=urlparser.parse(starturl); | |
var newurl=purl.protocol+"//"+purl.hostname+$("#pnnext").attr("href"); | |
setTimeout(function(){searchPage(newurl)},1337) | |
}catch(e){} | |
}); | |
}; | |
searchPage(starturl); |
This file contains 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 jquery=require("jquery"); | |
var jsdom =require("jsdom"); | |
exports.processUrl=function (url, cb){ | |
jsdom.env({ | |
html: url, | |
scripts: [], | |
done: function(errors, window) { | |
if(errors) | |
throw errors; | |
var $ = jquery.create(window); | |
$._X_win=window; | |
cb($); | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment