I'm currently writing a script that crawls a number of sites and dumps the results in a mongodb. When I run a bulk seed file (so I don't have to run each crawler and individual seed manually), The first crawler completes, but the following error hangs, preventing the rest of the steps from occuring.
fs: missing callback Error: ENOENT, open '../cache/nfHitters.json'
Below is my crawler code. Is there a way to remove this Error completely (or are there best practices I'm missing to prevent this from occuring all together)?
var cheerio = require("cheerio");
var request = require("request");
var json = require("json");
var fs = require('fs');
request('website-I-Am-Crawling.com',
function (error, response, html) {
if (!error && response.statusCode == 200) {
var $ = cheerio.load(html)
var variable = $('script')[3].children[0].data
var data = variable.substring(variable.indexOf("= ")+2, variable.indexOf(";"))
fs.writeFile('../cache/nfHitters.json', data, error)
};
});