casperjs

CasperJs Google login

六月ゝ 毕业季﹏ 提交于 2019-12-12 04:13:56
问题 I having been working on some code to access my google CSE For that I need to sign in with my google account. I have the following code: var casper = require('casper').create({ verbose: true, logLevel: 'debug', waitTimeout: 5000, clientScripts: ["libs/jquery.min.js"], userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4' }); const google_email = "MY_EMAIL"; const google_passwd = "MY_PASSWORD"; const loginUrl = 'https

is it possible to send email with casperjs?

允我心安 提交于 2019-12-12 04:02:55
问题 I am having a hard time finding examples of how to send an email with casperjs. This is my attempt so far... - I successfully got an API key from Mailgun. - I found 2 npm modules such as 'mailgun', and 'mailgun-js' - I loaded them and verified mailgun is loaded globablly and locally.. When I run my casper file. $ casperjs casper-test.js I get the following error: 'undefined' is not a constructor (evaluating 'new mailgun') var Mailgun = require('mailgun').Mailgun; var mg = new Mailgun('key

Phantomjs can't load iframe

拈花ヽ惹草 提交于 2019-12-12 03:44:35
问题 I'm a newbie, recently started to use phantomjs with casperjs. I want to get info from an iframe but phantomjs fails to load it. This is my script: var casper = require('casper').create({ verbose: true, logLevel: "debug", waitTimeout: 20000, retryTimeout: 100, viewportSize: { width: 1920, height: 1080 }, pageSettings: { "userAgent": 'Mozilla/5.0 (Windows NT 6.0) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.41 Safari/535.1' }, localToRemoteUrlAccessEnabled: true }); casper.start();

bypass cloudflare protection with casperjs or phantomjs while using tor proxy

我是研究僧i 提交于 2019-12-12 03:34:41
问题 I use tor to access casperjs via this socks proxy my OS windows 10 x64 my test.js var casper = require('casper').create({ verbose: true, logLevel: 'error', pageSettings: { loadImages: false, // The WebPage instance used by Casper will loadPlugins: false, // use these settings userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36' } }); var caturl = ('http://www.test.com'); casper.start(caturl, function() { this.echo(this

Is it possible to make “for” loop in CasperJS?

偶尔善良 提交于 2019-12-12 03:19:07
问题 It is additional question of How to stop a loop when clicking asynchronously in CasperJS I tried this code function execOnce(casper, i, max){ // end condition if (i === max) { return; } casper.wait(3000, function() { var button = x('//*[@id="content"]/div[3]/a['+i+']'); if (!this.exists(button)) { this.echo(i + " not available"); return; } this.thenClick(button, function (){ console.log('Searching dic'); words = words.concat(this.evaluate(getWords)); // recursive step execOnce(this, i+1, max)

What normal JavaScript functions are available in PhantomJS?

狂风中的少年 提交于 2019-12-12 03:15:38
问题 My question is best illustrated by example. I'm attempting to begin writing some regression tests in CasperJS. However, the website requires authentication (not Basic HTTP Auth), so I'll be using the setup option function to log in for the duration of the tests. However, I don't want to hardcode this into the script for obvious reasons. My solution is to read in the credentials from stdin using system . However, I am trying to use readLine since I don't know the length ahead of time. This

How to append json with no duplicating (including CasperJS code)?

为君一笑 提交于 2019-12-12 02:47:31
问题 I'm using CasperJS to parse inner texts of webpages and save to json file. Here is my code and I'll show you result(problem that I have) below! var words = []; var casper = require('casper').create(); var x = require('casper').selectXPath; var fs = require('fs'); function getWords() { var words = document.querySelectorAll('span.inner_tit'); return Array.prototype.map.call(words, function(e) { return e.innerHTML; }); } function createFinal(wordArray) { var out = []; wordArray.forEach(function

Passing a variable into an XPath expression in CasperJS

女生的网名这么多〃 提交于 2019-12-12 02:12:57
问题 I am using CasperJS to do some browser automation. Now I have an array, which contains text that can be found on some buttons that are randomly generated on the page. I pick a random button, and assign it to a variable, and now I want to find it, and click it based on its text value. I am having trouble building the XPath selector. so: var pickedButton = 'my button text'; this.click(x('//*[text()="my button text"]')); Can anyone point out how I can pass in a variable, instead of a string? 回答1

How can I run CasperJS files in Android?

≡放荡痞女 提交于 2019-12-12 02:05:34
问题 How can I install and run CasperJS files in Android? Is it possible? I would like to create an equal application droidscript with test functions and execute on a webview. 回答1: CasperJS is built on top of PhantomJS (and SlimerJS). Those are browsers themselves. They cannot be run in a WebView. It may be possible to compile, though I didn't find any documented trials. You should be able to port the PhantomJS API to an Android WebView and then make some adjustments to CasperJS so that it uses

Injecting javascript code into an on click event with javascript and casper.js

匆匆过客 提交于 2019-12-12 01:38:17
问题 I've just started using casperjs after trying to use python (selenium / requests and mechanise) to scrape a page only after some javascript loaded some dynamic content on the page. Since this was very hard to do or very slow with selenium it was suggested I turn to Casper js (which requires phantomjs). One thing I am wondering (I am quite new to javascript) is relating to a javascript onclick event. The page I want to scrape by default shows ten names per page, and at the bottom has options