node.js - Use nodejs short time write large amounts of data can't work -
i wrote crawlers using nodejs, go catch on key words of 100000 website, , writes results in txt file.but when second climb 100 websites , written file, cannot written file, program didn't work. may write fast. how solve?
sorry english poor!
'use strict'; let fs = require('fs'); let http = require('http'); var writable = fs.createwritestream(__dirname + '/write.txt'); var sitelist = ['engineeringcircle.com/']; let count = 0; setinterval(function() { doreq(); } , 10); function doreq() { http.get('http://' + sitelist[0], function(res) { console.log(count++); let findata = ''; res.setencoding('utf8'); res.on('data', (data) => { findata += data; }) res.on('end', () => { writable.write(findata); }) }) }
i'm using same website, don't errors if interval 10 ms, increase if still getting errors
Comments
Post a Comment