Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript NodeJS-http.request并单击链接_Javascript_Node.js_Asynchronous_Httprequest - Fatal编程技术网

Javascript NodeJS-http.request并单击链接

Javascript NodeJS-http.request并单击链接,javascript,node.js,asynchronous,httprequest,Javascript,Node.js,Asynchronous,Httprequest,我需要向这段代码添加什么才能使10%的http请求同时单击页面上的特定链接。我正在做网站转换测试 var http = require('http'); http.createServer(function() { }).listen(8124); // Prevent process shutting down var requestNo = 1; var maxRequests = 1000; function requestTest() { http.request({ hos

我需要向这段代码添加什么才能使10%的http请求同时单击页面上的特定链接。我正在做网站转换测试

var http = require('http');
http.createServer(function() { }).listen(8124); // Prevent process shutting down

var requestNo = 1;
var maxRequests = 1000;

function requestTest() {
    http.request({ host: 'www.mywebsite.com', method: 'GET' }, function(res) {
        console.log('Completed ' + (requestNo++));

        if (requestNo <= maxRequests) {
            requestTest();
        }
    }).end();
}

requestTest();
var http=require('http');
http.createServer(function(){}).listen(8124);//防止进程关闭
var-requestNo=1;
var maxRequests=1000;
函数requestTest(){
请求({host:'www.mywebsite.com',方法:'GET'},函数(res){
log('Completed'+(requestNo++));

如果(requestNo如果你需要“点击链接”,你可能需要一个全无头浏览器(一个没有用户界面的web浏览器的实现)


示例包括和

这10%需要准确吗?或者可能是随机的。您的意思是只跟踪一个链接(例如,向另一个URL发出请求)还是实际需要“运行”整个页面,包括Javascript和其他内容。它需要运行包含Javascript的页面才能发生跟踪事件。对于10%的用户,它可以是随机的,只要它占总访问量的10%左右。那么,你的意思是nodeJS无法加载页面并在没有无头浏览器的情况下实际执行操作?