Tag: phantomjs

无法在节点js上使用摩卡运行PhantomJS

我试图用这些参数运行phantomjs: mocha-phantomjs -s disk-cache=no –ignore-leaks -R xunit tests/index.html 但总是得到这个回应: events.js:72 throw er; // Unhandled 'error' event ^ Error: spawn ENOENT at errnoException (child_process.js:980:11) at Process.ChildProcess._handle.onexit (child_process.js:771:34) 我使用的是Ubuntu 13,mocha-phantomjs 3.1.0和v0.10.15。 任何谷歌search没有帮助,我只是不知道该怎么办。 所有我以前做的,只是安装节点和mocha-phantomjs 谁能帮我?

使用PhantomJs,Nodejs和MySQL

有没有办法使用PhantomJS刮取数据,然后用nodejs XPath和DOMparsing结果,然后保存到MySQL? 我已经安装了PhantomJS核心和PhantomJS Node模块,但是试图从shell级别运行Node来执行scraper,然后设置cronjobs来按计划运行它们。

NodeJS应用程序无法在heroku上构build… PhantomJS

我的应用程序不使用phantomjs作为直接依赖,也不使用业力 – 所以我很困惑,为什么我的应用程序将不再编译Heroku。 是否有可能强制所有软件包使用比1.9.7-1更新的版本? 5301 verbose linkStuff '/tmp/build_6198f9bd-484a-4d57-8f77-b337ced7ab58/node_modules/karma/node_modules/connect/node_modules' ] 5302 info linkStuff methods@0.0.1 5303 verbose linkBins methods@0.0.1 5304 verbose linkMans methods@0.0.1 5305 verbose rebuildBundles methods@0.0.1 5306 info install methods@0.0.1 5307 info postinstall methods@0.0.1 5308 info build /tmp/build_6198f9bd-484a-4d57-8f77-b337ced7ab58/node_modules/karma-phantomjs-launcher 5309 info preinstall karma-phantomjs-launcher@0.1.2 5310 verbose linkStuff [ false, 5310 verbose linkStuff false, 5310 verbose linkStuff false, 5310 […]

捕获网页图像的一些问题,node-webshot

我有一个web应用程序,用express框架在node.js中编写,在前端用Twitter Boostrap 3编写,我使用这个模块node-webshot为了保存页面的状态为png格式,当用户注销从我的网站,稍后显示给用户一个缩略图,他的最后一页的状态。 这个模块,工作真的很好,但我正在试验一些问题,例如: 在本地主机环境(OSX 10.9)上: 当我把我的应用程序放在我的Digital Ocean VPS(GNU / Linux – > CentOS 6.5)上时。 正如你所看到的,是两个不同的问题,第一个不能得到字形,第二个是失败,字符编码也许? 这是我的代码保存图像的一部分,并完美,除了这两个问题。 var options = { quality : 50, }; webshot(refererURL, './public/assets/img/lastScreen.png', options, function(err) { if(err) console.log('Error: some in screenshoot' , err); res.render('select_sys'); }); 在模块文档中,说这适用于幻像JS,有一些想法? 提前致谢。

没有find全局定义的variables

我已经声明了一个全局variablesvar linkArray=[] ,但是它并没有在phantomJS函数中被拾取。 错误消息是: phantom stdout: ReferenceError: Can't find variable: linkArray 。 我怎样才能find这个? 我试着用window.linkArray声明它,但是因为这是一个无头应用程序,所以我得到了一个不同的错误, ReferenceError: window is not defined 。 因此,我需要一种方法来使var linkArray=[]全局。 var phantom = require('phantom'); var linkArray=[]; phantom.create(function (ph) { ph.createPage(function (page) { var main_file="file:///C:/whatever/index.html"; page.open(main_file, function (status) { console.log("opened " + main_file +"\n",status+"\n"); page.evaluate(function () { for (var i=0; i < document.getElementsByTagName('a').length; i++) […]

使用nodeJS和phantomJS来返回networking请求和响应,只能在控制台中工作

我试图复制phantomJS netlog.jsfunction,只在nodeJS。 我正在使用phantomjs-node模块作为桥梁。 通常情况下,这个命令将在phantomjs netlog.js http://www.google.com/ 。 它会返回很多包含所有networking请求和响应的json。 我在这里做的是试图在使用phantomjs-node模块创build的页面内运行netlog.js的代码(忽略phantomjs-node var page = require('webpage').create() 。 虽然代码不会中断,但我没有得到json的返回。 这里有什么问题? 我是否需要以某种方式pipe理页面请求? 在app.js : var phantom = require('phantom'); siteUrl = "http://www.google.com/" phantom.create(function (ph) { ph.createPage(function (page) { var system = require('system'), address; page.open(siteUrl, function (status) { // console.log("opened " + siteUrl +"\n",status+"\n"); page.evaluate(function () { if (system.args.length === 1) { […]

当使用Nightmare.js或phantom.js来抓取网站时,为什么会显示幻像出现错误

我试图用phantom.js编写一个web-spider。 但是,我收到了很多错误信息,我不知道为什么。 我的代码如下所示: 使用Nightmare.js : var Nightmare = require('nightmare'); new Nightmare() .goto('http://www.amazon.com/Aroma-Housewares-ASP-137-3-Quart-Super/dp/B00024JQ3Q') .evaluate( function(){ return document.getElementById('priceblock_ourprice').textContent; }, function( numAnchors ){ console.log(numAnchors); }) .run(); 使用phantom.js : var page = require('webpage').create(); console.log('The default user agent is ' + page.settings.userAgent); page.open('http://www.amazon.com/Aroma-Housewares-ASP-137-3-Quart-Super/dp/B00024JQ3Q', function(status) { if (status !== 'success') { console.log('Unable to access network'); } else { var ua = […]

使用桥接获取PhantomJS返回的状态代码

我正在创build一个小API来监视我的一些站点的性能。 为此我需要加载时间和http状态码。 我使用节点js和phatomjs来做到这一点,到目前为止我的加载时间恰到好处,但我似乎无法得到状态代码。 我尝试了一些不同的东西,但没有一个工作到目前为止。 这是我现在的代码: var express = require('express'); var app = express(); app.get('/', function(req, res) { res.type('application/json'); res.send('{"status": "running"}'); }); app.get('/site/:url', function(req, res){ res.type('application/json'); res.header('Access-Control-Allow-Origin', '*'); res.header('Cache-Control', 'no-cache'); var url = decodeURIComponent(req.param('url')); var phantom = require('phantom'); var time, code; phantom.create(function(ph){ ph.createPage(function(page){ time = Date.now(); page.open(url, function(status){ time = Date.now() – time; res.send({"status": status, "time": […]

SpookyJS在meteor中使用时没有启动方法

我有一个奇怪的错误,无法find过去几个小时的原因… 我有一个meteor的应用程序,这刮了一些网页的信息,一切正常,只要我使用reuqest和cheerio静态页面,但现在我有一个dynamic的网站,我想要使用phantomjs,casperjs和spookyjs这个,但在这里我得到一些错误…我的代码如下,我在开始时导入npm模块: if (Meteor.isServer) { var cheerio = Meteor.npmRequire('cheerio'); var request = Meteor.npmRequire('request'); var phantomJS = Meteor.npmRequire('phantomjs'); var spooky = Meteor.npmRequire('spooky'); 有时候,我想用怪异的东西来刮一些网页: spooky.start("https://www.coursera.org/"); spooky.then( function () { this.fill("form", {email: user, password: pass}, true); });` 但只要我调用方法,我得到以下错误信息: 20150224-21:16:39.100(-5)? Exception while invoking method 'getLecturesCoursera' TypeError: Object function Spooky(options, callback) { …. I20150224-21:16:39.281(-5)? } has no method 'start' I20150224-21:16:39.281(-5)? […]

OpenShift错误:“phantomjs-node:你没有安装”phantomjs“

我在本地使用phantomjs-node成功创build了一个脚本,我想在OpenShift上托pipe。 事情是当我运行我的脚本托pipe,我有这个奇怪的错误: phantom stderr:execvp():没有这样的文件或目录phantomjs-node:你没有安装“phantomjs” 但正如你所看到的,我把依赖放在package.json文件中: "dependencies": { "express": "~3.4.4", "phantom": "*", "phantomjs": "*" }, 有什么build议么? 编辑: 这是我如何初始化phantomjs脚本: var options = { port: 16000, hostname: "127.2.149.1", path: "/phantom_path/" } phantom.create(function(ph) { visitUrl(ph, 0, 0); }, options);