I have an HTTP Get request and I want to parse the response and save it in my database.
If I call crawl (i) independently, I get good results. But I need to call crawl () from 1 to 2000. I get good results, but some answers seem to be lost, and some answers are duplicated. I donβt think I understand how to call thousands of asynchronous functions. I am using the async module function, but so far I still lack some data and still have some duplicates. What am I doing wrong here? Thank you for your help.
What i scan
My node functions:
function getOptions(i) { return { host: 'magicseaweed.com', path: '/syndicate/rss/index.php?id='+i+'&unit=uk', method: 'GET' } }; function crawl(i){ var req = http.request(getOptions(i), function(res) { res.on('data', function (body) { parseLocation(body); }); }); req.end(); } function parseLocation(body){ parser.parseString(body, function(err, result) { if(result && typeof result.rss != 'undefined') { var locationTitle = result.rss.channel[0].title; var locationString = result.rss.channel[0].item[0].link[0]; var location = new Location({ id: locationString.split('/')[2], name: locationTitle }); location.save(); } }); } N = 2
[EDIT] GOOD, after much testing, it seems that the service Iβm looking at cannot handle so many requests that itβs fast. Because when I execute each request sequentially, I can get all the good answers.
Is there a way to slow down the ASYNC queue method?
source share