如何使用node.js发送许多请求?
我写了这个脚本,但是.. console return有错误: 错误:连接ECONNREFUSED
我的代码
const request = require('request');
const headers = {
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "pl-PL,pl;q=0.8,en-US;q=0.6,en;q=0.4",
"Cache-Control": "max-age=0",
"Connection": "keep-alive",
"Cookie": "intro=1; PHPSESSID=cv2tniglt2v0fouov6jrjmblo6; chash=3373872b06; hs3=337; user_id=8464919; mchar_id=1107988; _gat=1; _ga=GA1.2.1270081288.1509529196; _gid=GA1.2.637535937.1509529196",
"Host": "www.margonem.pl",
"Referer": "https://www.margonem.pl/?task=profile&id=3727144",
"Upgrade-Insecure-Requests": 1,
"User-Agent": "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36 OPR/48.0.2685.52"
};
const options = {
url: "https://www.margonem.pl/?task=profile&id=3727144",
method: 'GET',
headers: headers
};
setInterval(() => {
request.get(options, function (error, response, body) {
console.log(error);
});
});
谁帮助我,并替换此脚本发送许多请求? 我想要更多的观点,你知道我的意思
答案 0 :(得分:0)
您目前所做的是拒绝服务(DOS)攻击。如果您从多个客户端执行此操作,它甚至可能是DDOS攻击。
让服务器有时间处理您的回复,例如通过例如一次只做一个连接。在呼叫的成功或错误回调中触发您的下一个请求。