Tag: casperjs

使用casperjs / phantomjslogging到Amazon Developer网页

我有一个问题,试图用CasperJSlogin到亚马逊开发者网页 – 电子邮件和通过成功input,但在“login”button单击,我收到一条消息,input一个有效的电子邮件(和我的电子邮件是有效的 – 我手动成功login)。 试图login到Facebook,它使用了几乎相同的代码。 我使用了这个网站的代码: http : //code-epicenter.com/how-to-login-to-amazon-using-casperjs-working-example/ 谢谢!

在casper方法之后从函数返回值

在下面的代码中,我想调用checkMainBox(cthis) 。 我想设置它,使这个函数将返回检索的数字或错误。 但在checkMainBox()我不知道如何返回一个值。 数字返回undefined。 我很确定我不能这样做,因为asynchronous行为,但下一个最好的方法是什么? function checkMainBox(cthis){ var number; cthis.waitForSelector("._XWk", function(){ cthis.capture("result.png"); cthis.then(function(){ var number = cthis.evaluate(function(){ return $("._XWk").txt(); }) // console.log("number", number); }) }) return number } function getPhoneNumber(cthis){ console.log("NUMBER::", checkMainBox(cthis)); //checkMainBox(cthis) should return false or the number } casper.on("error", function(msg){ this.echo("error: " + msg, "Error"); }) casper.on("page.error", function(msg, trace){ this.echo("Page Error: " […]

表单提交与casperjs – 新的url不加载

目标 在这里,我正在尝试在Pubmed网站上执行基本的search导航。 让我们说,我正在寻找的术语是Hello 。 我最后期望的是在点击searchbutton之后登陆一个结果页面。 问题 提交代码在Chrome浏览器的JavaScript控制台上完美工作。 但是它通过casperjs不起作用。 目前的url似乎保持不变。 我无法弄清楚问题在哪里。 我的代码 // USAGE: casperjs test navigation_test.js var config = { url: 'https://www.ncbi.nlm.nih.gov/pubmed/', }; config.form = { "term": "Hello", }; casper.test.begin('Testing navigation and forms', 2, function suite(test) { test.comment('⌚ Loading ' + config.url + '…'); casper.start(config.url, function() { // adjust the view port this.viewport(1280, 1024); }); […]

如何在Windows 7上使用NodeJS / PhantomJS / CasperJS

我需要刮一个网站forms(即时),其中有AJAX和SESSIONS。 我做了大量的研究,并且遇到了几个可能的解决scheme,一个是Python :: Mechanize。 我不知道Python的python和cURL(从我的理解)不能处理AJAX或提交表单。 我发现我相信是可能的堆栈,可以导致我的恩典:)。 问题是我根本不知道如何使用这些软件包。 我下载并安装了NODEjs,我可以从cmd中调用它。 (大) 我下载并安装PhantomJS(不知道如何设置PATH以便它是dynamic的,所以我必须在CMD中手动cd到DIR以使其加载)如何在Windows 7中设置此? 不知道在哪里指path。 下载CasperJS – 放入DIR 所以在phantomjs上,我能够运行一个testing文件,在CMD提示符中回显“hello world”。 而现在我不知道如何继续。 – 非常需要这个从我的web服务器上运行(即时) – 所以它需要被实现到我的网页。 到目前为止,我只想从CMD中运行它,然后转到一个页面,提交一个表单,刮取结果,并将其写入一个文件。 有人可以解释一下,像我可以做到这一点的工作stream程? CasperJS – >显示了这个表单的例子。 我想用我的variables来实现,运行脚本并保存结果。 casper.start('http://some.tld/contact.form', function() { this.fill('form#contact-form', { 'subject': 'I am watching you', 'content': 'So be careful.', 'civility': 'Mr', 'name': 'Chuck Norris', 'email': 'chuck@norris.com', 'cc': true, 'attachment': '/Users/chuck/roundhousekick.doc' }, true); […]

基于浏览器的Phantom / Caspertesting

我正在使用casper来testing用户界面或网站。 我想知道如果我可以在不同的浏览器,如使用casper的IE / Chrome / Firefoxtesting它们的兼容性。 此外,如果不能做到这一点,还有没有其他的方法来做到这一点,而不是从casper切换?

我如何在PhantomJS中使用deathbycaptcha

我正在开发CasperJS应用程序,并希望在我的脚本中使用deathbycaptcha。 我在网上search,但什么都没find。 问题来了,我不想使用PHP库。 并没有幻像的API。 我发现nodeJS的deathbycaptcha API,但我想为casperJS的API有没有办法做到这一点,如果任何人知道如何做到这一点,请帮助。 NodeJs库: https ://www.npmjs.org/package/deathbycaptcha 谢谢

查询CasperJS中的getElementInfo对象

我正在使用casperjs,并得到了一个我有这样一个对象的点: var domElem = this.getElementInfo(".foo"); 现在我想进一步查询domElem,如下所示: var domElemChild = domElem.QUERYFUNCTIONHERE(".bar"); 我不能这样做,因为domElem是一个对象,而不是一个DOM节点,我能做些什么(最好)只有casperjs? 注:我尝试使用cheerio,但它试图要求它输出以下错误: 错误:找不到模块'util' d是:/ dev /的Myproj / phantomjs:/bootstrap.js:289 D:/ dev / myproj / phantomjs:/bootstrap.js:254中的require D:/ dev / myproj / node_modules / cheerio / node_modules / htmlparser2 / lib / Pars er.js:120 D:/ dev / myproj / node_modules / cheerio / node_modules / htmlparser2 / lib […]

带有MongoDB NPM模块的CasperJS

我正在运行CasperJS 1.1.0-DEV,并要求mongoskin NPM模块将文档插入到Mongodb中。 但是使用mongoskin NPM模块 var mongo = require('mongoskin') var db = mongo.db('mongodb://localhost:27017/test', {native_parser: true})') 抛出错误 ReferenceError: Can't find variable: process /Users/username/casper-test/node_modules/mongoskin/index.js:1 /Users/username/casper-test/node_modules/mongoskin/index.js:2 TypeError: 'undefined' is not a function (evaluating 'mongo.db('mongodb://localhost:27017/test', {native_parser: true})') test.js:3 应该如何正确的使用CasperJS和mongoskin这样的NPM模块?

如何从MeteorJS应用程序运行在meteor服务器上的远程外部命令?

我创build了一些login到Duolingo的CasperJS脚本,点击模块并打开,如果我在那里玩。 我创build了一个简单的meteorJS应用程序,我希望当我点击一个button能够执行该casperjs脚本。 我正在寻找有经验的人来帮助我,或者以正确的方式导向我,因为我不知道我能用什么来实现这个小小的个人游戏。 我已经阅读了关于MeteorJS远程过程调用的RPC,并且我已经阅读了PHP和NodeJS,你可以运行一个执行脚本的函数,就像我input命令来运行脚本一样。 我find了这些资源:ShellJS: https : //github.com/shelljs/shelljs和NodeJSsubprocess: https ://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback。 但我没有太多的经验,我正在这样做,以更多地了解CasperJS,MeteorJS。 我需要的是能够运行这个命令 – >“casperjs duolingo.js –engine = slimerjs –disk-cache = no”使用我的Meteorjs应用程序,所以我可以继续创build我的小自动机器人来玩Duolingo整体。 非常感谢您的帮助。

在openshift服务器中的casperjs

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