Created
February 26, 2014 00:02
-
-
Save 1dolinski/9220625 to your computer and use it in GitHub Desktop.
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 cheerio = require('cheerio'); | |
var request = require('request'); | |
arry = [] | |
base_url = "https://weworkremotely.com" | |
function job_hrefs(i, url, arry, callback) { | |
return request(url, function(err, res, body) { | |
var jobs = []; | |
if (!err && res.statusCode == 200) { | |
$ = cheerio.load(body); | |
$('ul li a').each(function() { | |
var temp = {}; | |
temp.hrefs = $(this).attr('href'); | |
jobs.push(JSON.stringify(temp)) | |
}) | |
arry.push(jobs); | |
} | |
}) | |
}; | |
for (var i = 1; i < 8; i++) { | |
var url = base_url + "/categories/" + i + "/jobs" | |
job_hrefs(i, url, arry, function() { | |
console.log(arry); | |
// this isn't returning | |
// I think I'm missing something about | |
// how callback functions work | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment