Node.js 噩梦/电子:导航错误(代码-118)
与噩梦擦肩而过一直是件轻而易举的事,直到最近,我开始遇到没有细节的错误,标题是“导航错误” 以及错误代码118,如下所示Node.js 噩梦/电子:导航错误(代码-118),node.js,electron,nightmare,Node.js,Electron,Nightmare,与噩梦擦肩而过一直是件轻而易举的事,直到最近,我开始遇到没有细节的错误,标题是“导航错误” 以及错误代码118,如下所示 { [Error: navigation error] “0”: {消息:“导航错误”, 代码:-118, 详细信息:“”, url:''}, 长度:1, 错误: [{消息:“导航错误”, 代码:-118, 详细信息:“”, url:''}]} 我的噩梦代码(Node.Js): 函数*run(){ var噩梦=噩梦({show:true}); useragent(“Mozi
{ [Error: navigation error]
“0”:
{消息:“导航错误”,
代码:-118,
详细信息:“”,
url:''},
长度:1,
错误:
[{消息:“导航错误”,
代码:-118,
详细信息:“”,
url:''}]}
我的噩梦代码(Node.Js):
函数*run(){
var噩梦=噩梦({show:true});
useragent(“Mozilla/5.0(WindowsNT6.1)AppleWebKit/537.36(KHTML,比如Gecko)Chrome/41.0.2228.0Safari/537.36”)
变量url=”http://markets.ft.com/research/Browse-Companies";
var行业=[];
//获取{行业、链接、行业}格式的数据。
goto(url).inject('js',')./jquery-2.2.3.min.js').wait('wsod').evaluate(函数(){
var-arr=[];
$('.simpleLinkList.wsodModuleContent li')。每个(函数(){
arr.push({SECTOR:$(this).parents('ul').prev().text().replace('Sectors&Industries',''),
行业:$(this.text(),链接:$(this.find('a').attr('href')});
})
返回arr;
}).then(功能(数据){
行业=数据;
});
//使用{LINK}
var公司=[];
对于(var i=0;iindustry,为了方便起见,包含了部门名称
控制台.日志(公司)*/
控制台.日志(公司);
结束();
}
如果有人能提供更多关于这个错误的信息,那就太好了。这个程序有时可以运行,但大多数时候我都会遇到“导航错误”好的,在通过为electron+噩梦提供动力的chromium文档进行一些研究之后 错误代码-118与超时有关,但在实时浏览器上即时加载的网站上会弹出此问题 现在看起来像是一个电子错误,如果有人知道更多,请提供详细信息
function *run(){
var nightmare = Nightmare({show : true });
nightmare.useragent("Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36")
var url = "http://markets.ft.com/research/Browse-Companies";
var industry = [];
//fetching data in { INDUSTRY , LINK , SECTOR } format .
yield nightmare.goto(url).inject('js' , './jquery-2.2.3.min.js').wait('#wsod').evaluate(function () {
var arr = [];
$('.simpleLinkList.wsodModuleContent li').each(function(){
arr.push({SECTOR : $(this).parents('ul').prev().text().replace('Sectors & Industries' , '') ,
INDUSTRY : $(this).text() , LINK : $(this).find('a').attr('href')});
})
return arr;
}).then(function (data) {
industry = data;
});
//using {LINK}
var companies = [];
for(var i = 0 ; i<2; i++)
{
yield nightmare.goto(industry[i].LINK).inject('js' , './jquery-2.2.3.min.js').wait('#wsod');
var nextExists = yield nightmare.visible('.wsod-icon-paging-next-active');
var maxpage = 3;
var currentpage = 1;
var data = []; /* Object({ Name: "" , Link : ""})*/
while(nextExists && currentpage < maxpage)
{
//pagination / checking if next page exists and looping the scraper for each page
yield nightmare.evaluate(function(a , b){
var obj = [];
$('.company-link').each(function () {
obj.push({Sector : a , Industry: b , Name: $(this).text() , Link: $(this).attr('href')});
});
return obj;
},industry[i].SECTOR , industry[i].INDUSTRY).then(function (obj) {
data.push(obj);
});
yield nightmare.click('.wsod-icon-paging-next-active').wait(2000);
currentpage++;
nextExists = yield nightmare.visible('.wsod-icon-paging-next-active');
}
//data is an array of arrays and needs to be flattened.
var x = [].concat.apply([] , data);
//now pushing data to companies list (entire container)
companies.push(x);
}
companies = [].concat().apply([], companies);
//now companies is an array of entire list of all companies in every single sector->industry with sector name included for ease
console.log(companies);*/
console.log(companies);
yield nightmare.end();
}