Tag: phantomjs

承诺的节点骑士

我正在尝试使用骑士的评估function。 一个简单的例子: var Horseman = require('node-horseman'); var horseman = new Horseman(); horseman .open('http://google.com') .evaluate(function() { var promise = new Promise(function(resolve,reject){ setTimeout(function(){resolve("Hello")},2000); }); return promise; }) .then(function(mesg){ console.log(mesg); }) .close(); 我期待解决的价值“你好”被传递到下一个函数作为mesg参数当承诺履行,但相反,我得到以下错误: Unhandled rejection fn evaluate global code evaluateJavaScript@[native code] evaluate@phantomjs://platform/webpage.js:390:39 我错过了什么吗?

我正在得到问题phantomjs和业力

我在运行咕噜声时遇到问题,它引发了以下问题: 错误[启动]:PhantomJS2失败2次(超时)。 放弃。 DEBUG [karma]:运行完成,退出。 DEBUG [启动器]:断开所有浏览器 警告:任务“业力:连续”失败。 使用–force继续。 我试图运行npm install phantomjs 这是成功的。 之后,我运行npm install ,以及再次获得上述问题

使用PhantomJS处理多个用户请求到多个远程Web表单

我使用NightmareJS创build了一个ExpressJS应用程序,它有一个表单,当我们填写表单并提交时,它将请求发送给一些远程表单并计算数据并返回这些结果。 但问题是只有当单个客户提交表单时才有效。 当多个客户同时提交表单时,它不起作用。 这可能是什么原因以及如何解决这个问题? 前端JS脚本 $(document).ready(function () { $("#calculate-form").submit(function (event) { var request; if (request) { request.abort(); } var $form = $(this); var $inputs = $form.find("input, select, button, textarea"); var serializedData = $form.serialize(); $inputs.prop("disabled", true); form1(request, serializedData, $inputs, '/example1', '#form1'); function form1(request, serializedData, inputs, appUrl, displayElement) { request = $.ajax({ url: appUrl, type: "post", data: […]

NodeJs + PhantomJs从page.evaluate方法返回JQuery结果

NodeJS新手在这里。 我试图parsing使用NodeJS和PhamtomJS( phantomjs节点 )的HTML。 当我从浏览器控制台运行JQuery $("[class*='question-summary']") ,它返回一个数组。 但是,我无法在nodejs上做同样的事情。 我猜stackoverflow有JQuery所以我不需要使用includeJs来加载jQuery。 其实,当我跑步 这里是我正在运行的nodejs示例; var phantom = require('phantom'); async function getHtml() { const instance = await phantom.create([ "–load-images=false" ]); const page = await instance.createPage(); await page.on("onResourceRequested", function(requestData) { console.info('Requesting', requestData.url) }); const status = await page.open('http://stackoverflow.com'); console.log("STATUS: " + status); const content = await page.property('content'); console.log(content); var result […]

如何在客户端运行PhantomJS?

我正在使用HTML到PDF转换器,使用phantomjs和使用它的方式是这样的: npm install -g html-pdf var fs = require('fs'); var pdf = require('html-pdf'); var html = fs.readFileSync('./test/businesscard.html', 'utf8'); var options = { format: 'Letter' }; pdf.create(html, options).toFile('./businesscard.pdf', function(err, res) { if (err) return console.log(err); console.log(res); // { filename: '/app/businesscard.pdf' } }); 并在命令行中运行它,如html-pdf test/businesscard.html businesscard.pdf 现在我的问题是,如果我想在客户端使用它,而不是通过命令行input,我可以使用它与一个button或类似的东西。 我已经尝试过,但我失去了像child_process和fs(webpack problem but fixed) 。 有没有办法在客户端做到这一点?

PhantomJS错误

error: Could not spawn [/root/AgarioBotsV3/node_modules/phantomjsprebuilt/lib/phantom\bin\phantomjs.exe ] executable. Please make sure phantomjs is installed correctly. error: Error: spawn /root/AgarioBotsV3/node_modules/phantomjs- prebuilt/lib/phantom\bin\phantomjs.exe ENOENT at exports._errnoException (util.js:1016:11) at Process.ChildProcess._handle.onexit (internal/child_process.js:189:19) at onErrorNT (internal/child_process.js:366:16) at _combinedTickCallback (internal/process/next_tick.js:102:11) at process._tickCallback (internal/process/next_tick.js:161:9) at Function.Module.runMain (module.js:607:11) at startup (bootstrap_node.js:158:16) at bootstrap_node.js:575:3 error: Could not spawn [/root/AgarioBotsV3/node_modules/phantomjsprebuilt/lib/phantom\bin\phantomjs.exe ] executable. Please make sure phantomjs is […]

如何预装或将静态文件安装到Highchart的导出服务器中?

这是如此,如果我使用HTML导出图表,我可以引用样式类,所以我的图表将生成,因为它是在我的Web应用程序。 目前我尝试将CS​​S存储在我的resources.json文件中,但是这个样式似乎不适用于我的任何一个图表。 我知道在线样式标签适用于图表,当我在我的HTML中使用它,但是,因为我有很多的样式,最好加载它全部一次使用resources.json 更新 提供的命令d_paul工作,所以感谢你! 我试图用enableServer命令加载资源,但不会读取它。 无论如何,通过导出API http://api.highcharts.com/highcharts/exporting发送resources参数 我知道你可以发送JSON到服务器的资源参数,并让它以这种方式呈现,只是想知道是否有办法通过我上面链接的导出API发送它。 或者,如果不通过API,如果我可以加载资源,当我启动服务器使用enableServer参数?

当加载一个页面时,PhantomJs使用几个TCP连接

我使用PhantomJs来抓取一些网站,发现它打开几个TCP连接时加载甚至一页。 例如,以下是我的try.js: var args = require('system').args; var page = require('webpage').create(); var url = args[1]; page.open(url, function(status) { var title = page.evaluate(function() { return document.title; }); console.log('Page title is ' + title); //page.close(); }); 我试过了 phantomjs try.js http://www.google.com 发现它使用了4个连接。 我知道调用“page.close()”将closures所有连接。 但是如果我使用很多幻影进程,这样的问题仍然会导致大量的并发连接。 这是否发生,因为PhantomJs不使用持久的HTTP? 任何解决scheme

用phantomJS和NodeJS刮擦

我正在按照这里列出的教程: http://code.tutsplus.com/tutorials/screen-scraping-with-nodejs–net-25560 当我运行代码时: var host = 'http://www.shoutcast.com/?action=sub&cat=Hindi#134'; var phantom = require('phantom'); phantom.create(function(ph) { return ph.createPage(function(page) { return page.open(host, function(status) { console.log("opened site? ", status); page.injectJs('http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js', function() { //jQuery Loaded. //Wait for a bit for AJAX content to load on the page. Here, we are waiting 5 seconds. setTimeout(function() { return page.evaluate(function() { //Get what you […]

PhantomJS默认存储任何持久性文件吗?

作为PhantomJS的新用户,我想确保我了解PhantomJS如何处理从HTTP请求中累积的数据的任何持久性。 我的问题是: PhantomJS默认存储任何数据 (例如,在脚本的任何地方不使用require('fs')来存储请求,只是将其转储到STDOUT )。 我假设page.evaluate()调用的所有工作都是在内存中完成的。 下面是一个简单的例子: var page = require('webpage').create(), system = require('system'), address; if(system.args.length != 2) { console.log('Usage: phantomjs thisFile.js URL'); phantom.exit(1); } else { address = system.args[1]; page.open(address, function (status) { if(status !== 'success') { console.log('Unable to load the address!'); phantom.exit(1); } else { // Wait for the js to finish loading […]