Tag: 噩梦

电子:找不到模块“电子预制”

我有一个电子应用程序,使用Nightmare.js时,其中一个button被点击。 它在打包之前工作正常,但是在我用电子打包程序将其编译到.exe文件后,它将按预期工作,直到我点击使用Nightmare.js的button。 我得到这个错误: Uncaught Error: Cannot find module 'electron-prebuilt' at Module._resolveFilename (module.js:470) at Function.Module._resolveFilename (C:\app-directory\app-name-win32-ia32\resources\electron.asar\common\reset-search-paths.js:35) at Function.Module._load (module.js:418) at Module.require (module.js:498) at require (internal/module.js:20) at Object.<anonymous> (C:\app-directory\app-name-win32-ia32\resources\app\node_modules\nightmare\lib\nightmare.js:16) at Object.<anonymous> (C:\app-directory\app-name-win32-ia32\resources\app\node_modules\nightmare\lib\nightmare.js:528) at Module._compile (module.js:571) at Object.Module._extensions..js (module.js:580) at Module.load (module.js:488)

在Azure上启动Nightmare.js

我使用我的本地服务器上的恶梦,它的工作原理。 我试图在MS Azure上启动这个项目。 我在日志中看不到任何错误和警告。 但是在第一次使用“梦魇”期间,代码运行会停止。 我发现Azure不支持Electron。 Nightmare.js不适用于Azure webjob 有没有可能在Azure上运行我的代码? 如果没有,请告诉我梦魇工作的地方。 UPDATE 我在Windows上使用Azure Web Apps。 我遵循@evilSnobu的build议,并在Linux上的Azure Web Apps上重新启动我的服务器。 但是它不工作。 这样我在日志中看到,它工作,而不符合Nidthmare。 之后,我在日志(balnk14 – 它的我的项目)中看到这行: 2017-08-14 09:57:45.434 ERROR – Container logs STDERR>> 2017-08-14T09:53:58.254134911Z npm info it worked if it ends with ok 2017-08-14T09:53:58.254164596Z npm info using npm@3.10.10 2017-08-14T09:53:58.254167894Z npm info using node@v6.9.3 2017-08-14T09:54:00.107284364Z npm info lifecycle blank5@1.0.0~prestart: blank5@1.0.0 […]

我怎样才能同时使用2个电子窗口(Nightmare + Electron)?

我正在使用NightmareJS创buildnetworking自动化软件。 我想为我的软件创build一个graphics用户界面,但我不知道如何有一个电子窗口和无头NightmareJS进程在同一时间进行。 目标是通过GUI Electron线程来控制NightmareJS线程。 以下是我使用Nightmare的一些看法: const Promise = require("bluebird"); const Nightmare = require('nightmare'); require('nightmare-upload')(Nightmare); const vo = require('vo'); const realMouse = require('nightmare-real-mouse'); const request = require("request"); const qs = require('querystring') const EventEmitter = require("events").EventEmitter; const cheerio = require('cheerio'); const rp = require('request-promise'); var run = function* () { const nightmare = Nightmare({ show: true, switches: […]

使用噩梦 – 屏幕截图select器制作多个屏幕截图

我有一个“li”元素的网页。 我需要为每个“li”元素制作截图并将其保存到新文件中。 我正在尝试使用它的噩梦 – 截图select器。 但是我得到了一些截图相同,但名称不同的文件(从我的数组中)。 这是我的代码。 const Nightmare = require('nightmare'); const fs = require('fs'); const screenshotSelector = require('nightmare-screenshot-selector'); Nightmare.action('screenshotSelector', screenshotSelector); function savePicture(picture) { picture = ['v1', 'v2', 'v3']; let browser = Nightmare({ show: false, webPreferences: { partition: 'nopersist' } }); browser .goto('https://www.google.com') picture.forEach(v => { browser .wait(7000) .screenshotSelector(`li[class="${v}"]`) .then(function (data) { fs.writeFileSync(`img/${v}.png`, data) }) […]

如何从mysql中检索url到噩梦.goto funtion

我在MySql数据库中有一些URL。 这些URL我想要一个接一个地传递给nightmare.goto()然后评估网站。 一旦完成,我想另一个URL传递到nightmare.goto()以便我可以评估数据库中的所有URL。 我该怎么做? 例如: nightmare .goto('firsturl.com') .wait(2000) 评估完成..然后再次 nightmare .goto('secondurl.com')

如何用nightmarejs正确地停止phantomjs实例

我想用恶梦获取我的networking应用程序的屏幕截图。 运行代码时没有错误,退出是干净的,没有pha​​ntomjs实例被留下。 var Nightmare = require('nightmare'); var Screenshot = require('nightmare-screenshot'); var nightmare = new Nightmare(); var url = process.argv[2]; var url = process.argv[3]; nightmare .goto(url) .wait('#selector') .use(Screenshot.screenshotSelector(path, '#selector')) .run(function (err, nightmare) { if (err) console.log('Error'); else console.log('Done.'); nightmare.teardownInstance(); nightmare.end(); }); 但是,当有一些错误,如networking没有运行,select器不存在。 幻影的实例仍然未被使用。 $ ps -ax | grep phantom 6065 ttys004 0:00.00 grep phantom 6050 ttys005 […]

发送keydown,在nightmare.js中键入按键

在nightmare.js中的types方法将文本分配给input控件的值属性。 由于这个实现keydown,keypress事件不会触发你正在试图抓取的页面上。 任何方式发送'types'后的keydown事件? 编辑1- 这是一个使用jQuery发送事件的例子, var Nightmare = require('nightmare'); var vo = require('vo'); var nightmare = Nightmare(); vo(run)(function(err, result) { if (err) throw err; }); function *run() { var title = yield nightmare .goto('http://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes') .type('#txtChar','\n') .evaluate(function() { var e = $.Event( "keypress", { which: 13 } ); $('#txtChar').trigger(e); return "Key you pressed is : " […]

与NightmareJS的asynchronous问题

我正在尝试使用nightmarejs来构build一个脚本,这个脚本可以一次又一次地点击一个button,就像在评论部分底部的那个button一样,每次按下它时都会载入较旧的评论(例如:youtube.com/观看?v = pZISJqJbQuU&list = RDpZISJqJbQuU#t = 3),并在没有更多button被点击时停止。 我曾尝试调用评估,只为end()方法先被调用,并取消进程。 我已经尝试使用setTimeout,setInterval,然后(),将循环转换为recursion。 每次评估()都会完成它的工作,但是在完成工作之前不能退出(只是挂起)或者退出,因为和end()的竞争条件。 有没有经验丰富的nightmarejs用户? function youtube_button_clicker(group) { var nightmare = Nightmare({ show: true }); nightmare .goto(url) .inject('js', 'jquery-3.1.0.js') .then( () => nightmare. evaluate(function() { for (i=0;i>LEN;i++) { setTimeout(() => { $(button_element).click() }, i * 2000); } return "done" })) .catch(function (error) { console.error('Search failed:', error); }); } 删除.end()方法并挂起,重新放置.end(),并跳过该过程 […]

点击function不执行Nightmare.js执行

我试图做一些nightmare ,我的工作几乎function。 问题是当我在evaluate()和run()被调用之后尝试执行click()时,我遇到了一个问题。 在我运行这两个函数之后,我试图执行另一个单击来将自己移动到网站的另一部分,但不执行click() 。 在这一点上,我记下确定最新的问题,我有几个假设,也许这些function是asynchronous的,我试图click()时,callback还没有准备好,或者其中一个function结束de当前nightmare对象,我不dont有范围了。 var Nightmare = require('nightmare'); //var nightmare = Nightmare({show:true}) var express = require('express'); var fs = require('fs'); var request = require('request'); var cheerio = require('cheerio'); var app = express(); var urlWeb = "someurl"; var selectCity = "#ddl_city"; var selectTheater = "#ddl_theater"; var enterBtn = "#btn_enter"; var mainSelector = "#aspnetForm"; var […]

如何使用NightmareJS进行多个查询?

下面的Javascript是打算使用NightmareJS来search一个网站的3个职位,并返回谁上传的职位的用户名。 var Nightmare = require('nightmare'); var nightmare = Nightmare({ show: true }); var inputArray = [198,199,201]; var runNext = function (i) { nightmare .goto('http://theshitpit.com/goto.php') .insert('form [name=postnum]', i) .click('form [type=submit]') .wait() .evaluate(function () { return document.querySelector('.username').innerHTML }) .end() .then(function (result) { console.log(result) }) .catch(function (error) { console.error('Search failed:', error); }); } var index = 0; while(index<inputArray.length){ […]