问题标签 [nightmare]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
1056 浏览

javascript - nightmarejs document.getElementsByClassName() 返回空对象

我正在尝试从 Stackoverflow 主页获取问题标题。下面是我的 nightmareJS 代码。

当我在 Chrome 控制台中运行时,它可以工作。

结果 Chrome 控制台

然而,在 nightmareJS 中,这是我的输出。

感谢关于为什么我的对象是空的建议。请参阅图像以获取 HTML 和 Chrome 控制台的屏幕截图以及结果。

0 投票
0 回答
905 浏览

node.js - 使用 Nightmare 进行动态网站抓取

我正在尝试使用 Nightmare.js(for Node.js) 废弃 Google 搜索。我基本上是在搜索一个词(我不想去谷歌主页并从那里导航,因为输入将是一组预定义的 URL)并为其截取屏幕截图。由于谷歌搜索是由 javascripts 动态加载的,所以我遇到了麻烦,我的屏幕截图是空白的。谁能指出这个问题?这是我使用的代码。

0 投票
1 回答
2441 浏览

javascript - Javascript - Nightmare.JS 无限滚动动作

我在这里做错了什么?我想向下滚动一个页面,直到选择器消失。

我正在使用:

0 投票
1 回答
1513 浏览

node.js - 噩梦/电子:导航错误(代码 - 118)

直到最近,使用噩梦进行抓取一直是轻而易举的事,我开始遇到没有详细信息的错误,标题为“导航错误”和错误代码 118,如下所示。

'0':{消息:'导航错误',代码:-118,详细信息:'',url:' http ://markets.ft.com/research/Browse-Companies '},长度:1,错误:[ {消息:'导航错误',代码:-118,详细信息:'',网址:' http ://markets.ft.com/research/Browse-Companies '}]}

我的噩梦代码(Node.Js):

如果有人可以提供有关此错误的更多信息,那就太好了。该程序有时有效,但大多数时候我得到“导航错误”

0 投票
1 回答
1815 浏览

node.js - Is it possible to pass information from browser to Node scope using Nightmare.js (v2 Electron)?

I am using Nightmare.js (v2.3.3) to automate a part of my workflow where I have to access a website that updates our database. I have been able to get Nightmare working for basic things like .type, .click, and .screenshot to validate that I am accessing these pages and inputting the information I intended.

Where I have been stuck, and the documentation seems lacking, is using .evaluate to extract information from the page. In the documentation it has it as:

This is all well and good, but is it actually possible to go the opposite direction and pass information from browser scope to Node scope? What I would like to do is return all of the checkboxes on a page as an array, and then loop through them in the Nightmare script.

I also searched through many GitHub issues and StackOverflow questions to find an answer, and the problem seems to be that previous versions were built off of PhantomJS and v2+ is using Electron, so it is difficult to distinguish which answers actually still apply to the current version. Here is an answer that seemed to make sense to me, but it was in 2014 so I am thinking that most likely it was a PhantomJS version. For reference, this is the snippet that seemed to have an answer on how to transfer from browser to Node scope:

But it does not seem that the current version of Nightmare supports this .evaluate(fn, cb, arg1, arg2,...) format?

I would just like to know if this is possible before I drive myself crazy! Thanks for any and all help, please let me know if you need any additional information to help answer.

0 投票
1 回答
1784 浏览

javascript - 如何按数组内容的顺序执行 async.map 函数

我有以下代码例程,效果很好。唯一的问题是我需要以与links数组相同的顺序返回结果。例如,我需要首先返回 google.com 链接的结果,然后是 yahoo 等。代码当前以“随机”顺序返回。

更新:谢谢@christophetd。这是我修改后的工作代码:

0 投票
1 回答
672 浏览

node.js - Heroku 上的 Nightmare.JS 导致超时

我正在建立一个网站,当人们在 URL 的请求部分将他们的凭据输入到网站时,它会将他们登录到该网站并发回有关他们帐户的数据。在本地测试此代码不会产生错误并且发生得相当快。我不确定是什么导致它在服务器上而不是在本地超时。

这是来自的日志文件heroku logs

配置文件包含运行此文件的命令

这是scrape.js

提前感谢您的帮助!

0 投票
2 回答
919 浏览

javascript - NightmareJS 无法使用 vo 进行评估

我正在尝试将 NightmareJS v2 和 Vo 与 Node.JS 一起使用来浏览一些搜索词并从中收集数据。我的代码如下所示:

根据 NightmareJS 的文档,如果你在里面返回一些东西,evaluate那么当你使用then. 当我尝试这个时,我变得不确定。我认为它与发电机有关,但我对它们很陌生,所以我不能说。帮助表示赞赏。

0 投票
2 回答
2229 浏览

node.js - How to run nightmare.js on google appengine for node.js

There is famous issue with nightmare and electron not running on headless linux servers. The official electron docs suggest to use xvfb in order to fake the display. They suggest to use this .yml file for travis.

Question

How can I use the above piece of code into app.yaml file of google appengine for node.js. I have tried to use this as it is, but glcoud throws an error that addon is invalid command. The gap official docs don't have any similar command.

Any suggestions how we can run nightmare and electron on google appengine for node.js..?

0 投票
2 回答
2169 浏览

javascript - 噩梦 .click 事件 onclick

我正在尝试单击“onclick”元素。目标网站的来源是

我想点击'select2'。

我试过这个,但它不起作用:

如何点击元素.select2

谢谢。