Tag: casperjs

使用casperjs“使用Facebooklogin”实现

我看到很多网站可以select使用Facebook (airbnb,about.me等)login。 我想要使​​用Facebook帐户实现自动login到这些网站(以后者)。 这是about.me的代码: var casper = require('casper').create(); var fbUsername = casper.cli.args[0] var fbPassword = casper.cli.args[1] // login to facebook casper.start('https://www.facebook.com/login.php?', function() { this.fill('form#login_form', { 'email': fbUsername, 'pass': fbPassword, },true) }); casper.thenOpen("https://about.me/login",function() { this.waitForSelector('#facebook_login',function() { this.click('#facebook_login') }) }); casper.thenOpen("https://about.me/account/#!/myinformation",function() { this.debugHTML() }) casper.run(); 我看到我login到Facebook,但是对于我尝试过的每个网站,我都无法login,因为“facebooklogin”上的新闻没有正常工作(每次都是)。 任何人都可以帮助我了解问题在哪里,我该如何解决?

幻影挂在主页上

我有这个代码作为test.js: var page = require('webpage').create(); console.log('The default user agent is ' + page.settings.userAgent); page.settings.userAgent = 'Mozilla/5.0'; //page.onResourceRequested = function(request) {}; //page.onResourceReceived = function(response) {}; page.open('http://www.skadden.com',function(status){ console.log("Status: " + status); phantom.exit(); }); 当我运行这些命令时,为什么Phantom会间歇性挂起? phantomjs –debug=true –web-security=false –load-images=true test.js 挂起在[DEBUG]networking – 资源请求错误:203(“错误下载http://www.skadden.com/sites/all/themes/skadden_​​main/images/menu_links.png – 服务器答复:未find”)URL:“ http://www.skadden.com/sites/all/themes/skadden_​​main/images/menu_links.png “ phantomjs –debug=true –web-security=false –load-images=false test.js 作品有时,但也将挂在[debugging] CookieJar – 保存“has_js = 1;域= […]

Phantomjs 2.0 SocketIO每个连接需要1000毫秒

我使用PhantomJS 2.0并试图在PhantomJS和NodeJS之间testingsocket.io。 它的工作原理,但每个连接需要大量的时间(约1000毫秒)。 我曾在Chrome上试过,它只需要1-2ms。 看来PhantomJS的page.evaluate中的socket.io不是socket.io! 这是我使用CasperJS的testing代码: var casper = require('casper').create({ clientScripts:["socket.io.js"] }); casper.start('http://localhost:8080'); casper.page.onConsoleMessage = function(msg) { console.log(msg); }; }; casper.then(function(){ this.evaluate(function(){ var socket = io.connect('http://localhost:8080'); socket.on('news', function (data) { socket.emit('senddata', { time: new Date().getTime() }); }); }) }) casper.wait(5000); casper.run(); 在NodeJS服务器上,我使用下面的代码: var app = require('http').createServer(handler) var io = require('socket.io')(app); var fs = require('fs'); app.listen(8080); […]

尝试使用casperjslogin到网站。 提交表单会产生一个ajax请求

捕获的结果给了我一个login页面的图片,它带有一个正在进行的gif,它没有显示仪表盘的图片,或者是什么login后的页面,这是我想要的。 我尝试使用所有types的waitfor(),但我失败了。 var casper = require("casper").create({ userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22', pageSettings : { userAgent : "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36" }, verbose : true, logLevel : "debug", clientScripts : ["jquery.js"] }) var fs = require("fs"); casper.on("error", function(msg){ this.echo("error: " […]

在AWS弹性beanstalk上产生casperjs ENOENT错误

我正在试图使用SPOOKY在nodejs上运行casper scraper。 当我在本地主机上运行时,scrapper工作正常,但是当我在AWS elastic beanstalk服务器上部署项目时,出现以下错误。 Error: spawn casperjs ENOENT at exports._errnoException (util.js:1018:11) at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32) at onErrorNT (internal/child_process.js:367:16) at _combinedTickCallback (internal/process/next_tick.js:80:11) at process._tickCallback (internal/process/next_tick.js:104:9) [nodemon] app crashed – waiting for file changes before starting… 我已经尝试设置binPath: './node_modules/casperjs/bin/casperjs'"并试图在全球范围内安装Casper,但无法执行此操作,还添加了command: /^win/.test(process.platform) ? 'casperjs.cmd' : 'casperjs',给孩子,但是也没有成功。 我一直在寻找这一个多星期,但没有成功。 请帮我解决这个问题。

使用Spooky.js运行示例代码时出错

我是新来的整个phantom.js , casper.js , casper.js和spooky.js 。 我已经安装了所有的东西(在Windows中),更新PATH并遵循这个例子: https://github.com/WaterfallEngineering/SpookyJS 我得到这个错误: C:\node_modules\spooky>node examples/hello.js events.js:68 throw arguments[1]; // Unhandled 'error' event ^ Error: Child terminated with non-zero exit code 127 at Spooky._spawnChild.Spooky._instances.(anonymous function) (C:\node_module s\spooky\lib\spooky.js:82:17) at ChildProcess.EventEmitter.emit (events.js:96:17) at Process._handle.onexit (child_process.js:678:10) 任何人有任何线索为什么和如何解决它? 我运行casperjs googlelinks.js就好了。 但是使用node.js和spooky.js ,这给我带来了麻烦。

如何将数据从casperJS传递到nodeJS?

我在casperJS中构build了一个刮板,用于从Google+页面中提取数据。 它工作出色。 现在我想能够在我的nodeJS服务器中添加一个API GET调用,它将抓取这些数据并以JSON格式返回。 除了在这里的testing场景,我没有find任何关于如何完成这个任务的文档或内容。 还有一些鬼怪 ,但在9个月内还没有更新,人们都说它很破碎。 任何指导,使之成为可能将不胜​​感激。

我如何在CasperJS中需要MongoDB?

我正尝试从CasperJS中将logging插入到MongoDB集合中,但在第一个障碍中,我被阻塞了。 我首先通过在我的应用程序的根目录下运行以下命令来安装mongodb: npm install mongodb 这成功完成没有任何错误。 我有一个名为server.js的CasperJS文件,其中包含以下行: var db = require('mongodb'); 当我尝试运行casperjs server.js ,我得到以下错误: js-bson: Failed to load c++ bson extension, using pure JS version Error: Cannot find module 'util' /home/aaron/Documents/git/mateserver/phantomjs:/bootstrap.js:289 /home/aaron/Documents/git/mateserver/phantomjs:/bootstrap.js:254 in require /home/aaron/Documents/git/mateserver/node_modules/mongodb/lib/mongodb/commands/insert_command.js:2 /home/aaron/Documents/git/mateserver/node_modules/mongodb/lib/mongodb/commands/insert_command.js:162 似乎我缺less一个包,所以我运行命令: npm install util 哪个运行成功,所以我尝试再次启动我的应用程序,但得到这个错误: js-bson: Failed to load c++ bson extension, using pure JS version TypeError: 'undefined' is […]

如何调用SpookyJS中的函数?

我有一个叫做clickMore的函数: function clickMore(max, i){ i = i || 0; if ((max == null || i < max) && this.visible(moreButton)) { // synchronous // asynchronous steps… this.thenClick(moreButton); // sometimes the click is not properly dispatched this.echo('click'); this.waitUntilVisible(loadingButton); this.waitUntilVisible(moreButton, null, function onTimeout(){ // only placeholder so that the script doesn't "die" here if the end is reached […]

减less无限循环中的phantomjs / casperjs / spookyjs内存使用

我试图刮一个页面,使用phantomjs casperjs和幽灵般的无限滚动。 它应该继续点击更多的button,并从结果中的新链接,直到手动停止。 然而脚本开始使用越来越多的内存,直到它崩溃。 我写了下面的脚本,有没有一种方法来优化它,所以它不会使用更多的内存: function pressMore(previousLinksLength) { this.click('#projects > div.container-flex.px2 > div > a'); this.wait(1000, function() { links = this.evaluate(function() { var projectPreview = document.querySelectorAll('.project-thumbnail a'); return Array.prototype.map.call(projectPreview, function(e) { return e.getAttribute('href'); }); }); this.emit('sendScrapedLinks', links.slice(previousLinksLength)); // repeat scrape function pressMore.call(this, links.length); }); } // spookyjs starts here spooky.start(scrapingUrl); //press the more button spooky.then(pressMore); […]