我的javascript代码应该从大约0到450进行for循环。在每次迭代时,它应该将整个网页划分为一个字符串。大约20个成功请求后,它崩溃并出错。无论它正在处理哪个网址,我都会得到相同的结果
for (var x =0; x<projects.length; x++){
//get data from url
urllib.request(urls[0], function(err, data, res) {
if (err || res.statusCode != 200) {
console.log("error try again");
} else {
data_taken = data.toString();
console.log(data_taken);
}
});
我得到了一堆成功的结果然后我得到了这个
error try again
error try again
error try again
error try again
error try again
error try again
error try again
error try again
error try again
error try again
error try again
error try again
error try again
error try again
error try again
我觉得javascript正试图过快地处理请求。它肯定会在负载下崩溃