Tag: phantomjs

如何解决噩梦.click()问题不传播?

我已经减less了我与这个最小的例子与公共网站的问题。 点击“全部显示”button会触发更多的网站在每个浏览器中都可见,但不是噩梦: var Nightmare = require('nightmare'); new Nightmare({timeout: 60000}) .viewport(1920, 10000) .goto('http://mtv.de/charts/5-hitlist-germany-top-100') .wait(10000) .screenshot('before.png') .click('div#content div.chart-container a.button.show-all') .wait(20000) .screenshot('after.png') .run(); 我甚至试图用jQuery('…').trigger('click')触发点击jQuery('…').trigger('click') ,它可以在Chrome中工作,但不是在恶梦中.evaluate(…) 。 这里是运行上面的例子的debugging输出,没有什么特别的: nightmare queueing action "viewport" +0ms nightmare queueing action "goto" +3ms nightmare queueing action "wait" +0ms nightmare queueing action "screenshot" +0ms nightmare queueing action "click" +0ms nightmare queueing action "wait" +0ms nightmare […]

我们如何访问PhantomJS下载的文件?

我正在使用PhantomJS通过https://github.com/sgentle/phantomjs-node/加载一个网页,并想知道 我怎样才能阻止它加载图像文件? 我如何访问已经由PhantomJS下载的文件? 为什么PhantomJS的屏幕截图与我的浏览器中显示的不同? 附在下面

PhantomJs返回未定义的page.title

从PhantomJs控制台input var page = require('webpage').create();page.open('http://phantomjs.org', function (status) {console.log(page.title);}); 它不打印页面标题,但只是未定义 为什么?

使用PhantomJS将多个页面渲染为pdf文件

我需要使用PhantomJS将多个页面渲染成pdf文件。 一旦PhantomJS渲染一个页面,另一个实例不能被调用,直到完成前一个执行。 我相信它将需要一些types的callback和recursion方法。 以下是呈现单个页面的代码: someUrl = "https://www.google.com/"; var phantom = require('phantom'); phantom.create(function(ph){ ph.createPage(function(page) { page.open(someUrl, function(){ page.render('google.pdf'); //needs to wait for this to finish ph.exit(); //to call itself for the next url }); }); });

在openshift服务器中的casperjs

在openshift服务器中,我们没有root权限,这就是为什么我们不能在全局安装任何npm包。 我的问题是如何在openshift服务器中设置和获得casperjs和phantomjs一起工作。

在phantomjs中使用“window.onload”

我使用PhantomJS通过npm-phantom模块从基于AJAX的页面中抓取数据。 有时数据在幻像开始DOM遍历时尚未加载。 如何在page.evaluate插入类似window.onload = function() { … }的page.evaluate ? 它返回给我一个函数,但不是数据。 var phantom = require('phantom'); exports.main = function (url, callback) { phantom.create(function (ph) { ph.createPage(function (page) { page.open(pref + url, function (status) { page.evaluate(function () { // here var data = {}; data.one = document.getElementById("first").innerText; data.two = document.getElementById("last").innerText; return data; }, function (res) { callback(null, res); […]

PhantomJS的Npm安装挂起

任何时候我试图通过包含phantomJS的npm来安装package.json,或者使用它作为依赖包的包,安装将在phantomJS安装上挂起。 没有线索会导致这个,有什么想法? >$ npm install | > phantomjs@1.9.7-10 install c:\Users\user\application\node_modules\grunt-mo cha\node_modules\grunt-lib-phantomjs\node_modules\phantomjs > node install.js \ 它只是无限期地呆在那里(最后一个斜杠旋转) 详细输出: npm info install sntp@0.2.4 into c:\Users\Nick\extensionTest\node_modules\phan tomjs\node_modules\request\node_modules\hawk npm info install cryptiles@0.2.2 into c:\Users\Nick\extensionTest\node_modules \phantomjs\node_modules\request\node_modules\hawk npm info install boom@0.4.2 into c:\Users\Nick\extensionTest\node_modules\phan tomjs\node_modules\request\node_modules\hawk npm info installOne hoek@0.9.1 npm info installOne sntp@0.2.4 npm info installOne cryptiles@0.2.2 npm info installOne boom@0.4.2 npm […]

Mocha-phantomjstesting没有输出

我已经在这里成功安装了节点模块“mocha-phantomjs”。 我写了下面的testing用例: test1.js describe("DOM Tests", function () { var el = document.createElement("div"); el.id = "myDiv"; el.innerHTML = "Hi there!"; el.style.background = "#ccc"; document.body.appendChild(el); var myEl = document.getElementById('myDiv'); it("is in the DOM", function () { expect(myEl).to.equal(null); }); it("is a child of the body", function () { expect(myEl.parentElement).to.equal(document.body); }); it("has the right text", function () { expect(myEl.innerHTML).to.equal("Hi […]

Node.io,JSDOM或PhantomJs? 或者,YQL-data.html.cssselect?

我需要抓取一个特定的网站挖掘出一些相关的信息。 看起来像首先我必须search该网站,以获得相应的url,抓取时会给我的详细信息。 我们假设,searchurl是 example.com/city1/search.html?cat=category1&locality=location1&page=1 这意味着,可以有city2,city3等类别可以是category2,category3等等,用于位置和页面。 我收集了所有的城市,类别,地点和页面可以增加,直到结果不为空。 得到所有的url后,我必须从每个url挖掘出详细的信息。 我已经看到,某些必要的信息可作为JavaScript的一部分。 现在,我已经看到了node.io,jsdom和phantomjs。 我也看到了yql。 由于我是新手,请根据您的经验向我build议,在这种情况下哪一个是最理想的。 如果你可以举一些例子,那就太棒了。

幻影+摩卡+节点+打开网页

我正在尝试做一些非常简单的事情。 或者我想。 我想要做的就是使用phantomjs打开一个网页并声明其标题。 我正在使用mocha-phantomjs来调用我的testing运行器,如下所示: <html> <head> <meta charset="utf-8"> <link rel="stylesheet" href="../../node_modules/mocha/mocha.css" /> </head> <body> <div id="mocha"></div> <script src="../../node_modules/mocha/mocha.js"></script> <script src="../../node_modules/chai/chai.js"></script> <script> mocha.ui('bdd'); mocha.reporter('html'); </script> <script src="test.js"></script> <script> if (window.mochaPhantomJS) { mochaPhantomJS.run(); } else { mocha.run(); } </script> </body> </html> 和我的testing文件看起来 (function() { var page, url; page = require('webpage'); page = webpage.create(); url = "http://localhost:3000"; page.open(url, […]