使用 PhantomJS 返回 xhr 请求列表

问题描述

我正在尝试返回 https://www.canada.ca/en.html 的 xhr 请求的链接地址

当您第一次访问该网站时,有 4 个 xhr 请求。到目前为止,我有以下使用 PhantomJS

var webpage = require('webpage');

var page = webpage.create();

var page = require('webpage').create();
page.onResourceRequested = function(request) {
  console.log('Request ' + JSON.stringify(request,undefined,4));
};
page.onResourceReceived = function(response) {
  console.log('Receive ' + JSON.stringify(response,4));
};
page.open('https://www.canada.ca/en.html');
phantom.exit();

这给了我以下回复

Request {
    "headers": [
        {
            "name": "Accept","value": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
        },{
            "name": "User-Agent","value": "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/538.1 (KHTML,like Gecko) PhantomJS/2.1.1 Safari/538.1"
        }
    ],"id": 1,"method": "GET","time": "2021-02-07T21:13:05.150Z","url": "https://www.canada.ca/en.html"
}
Receive {
    "contentType": null,"headers": [],"redirectURL": null,"stage": "end","status": null,"statusText": null,"time": "2021-02-07T21:13:05.212Z","url": "https://www.canada.ca/en.html"
}

如何提取四个xhr请求的链接地址

提前致谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)