casperjs

Scraping an infinite scroll page stops without scrolling

半城伤御伤魂 提交于 2019-12-23 12:14:20
问题 I am currently working with PhantomJS and CasperJS to scrape for links in a website. The site uses javascript to dynamically load results. The below snippet however is not getting me all the results the page contains. What I need is to scroll down to the bottom of the page, see if the spinner shows up (meaning there’s more content still to come), wait until the new content had loaded and then keep scrolling until no more new content was shown. Then store the links with class name .title in an

Scraping text from lightbox using casperjs

折月煮酒 提交于 2019-12-23 05:26:17
问题 I'm using casperjs to scrape text from a website and so far it works fine. However, this page that I'm scraping from has hundreds of products on it and some of these products have an orange button next to them. The orange button has a class of button small orange . If you click on this orange button it will bring up a light box with a description of the product. How would I have casper click on the orange button if it's there then scrape the description, then exit the light box then keep on

Pass params like variable to evaluate in casperjs and login into site

一曲冷凌霜 提交于 2019-12-23 05:24:12
问题 I'm writing a python script that pass username and password like params to my casperjs script, describe below. But I don't know why a receive the error: CasperError: casper.test property is only available using the `casperjs test` command C:/casperjs/modules/casper.js:179 Can someone help me about this issue? CasperJS.py: import os import subprocess # PATH to files casperjs = 'c:\casperjs\bin\casperjs.exe' app_root = os.path.dirname(os.path.realpath(__file__)) script = os.path.join(app_root,

How do I remove the stack overflow from this casperjs code (using setTimeout)?

≯℡__Kan透↙ 提交于 2019-12-23 02:10:09
问题 The following sample resembles my actual code: function runCode() { casper.then(function(){ if (condition){ return; } }); .... code ..... .... code ..... casper.then(function(){ setTimeout(runCode(), 1000); }); } function startScript() { .... code .... .... code .... casper.then(function(){ runCode(); }); casper.then(function(){ setTimeout(startScript(),5000); }); } startScript(); This code is running on a vps and it seems to fill up all the 512 MB of RAM. It initially starts with around 50

How use --config with CasperJS

被刻印的时光 ゝ 提交于 2019-12-22 18:39:12
问题 I've read the Casper documentation and they say that ALL PhantonJS cli options is available on CasperJS but I am trying to use --config=/path/to/config.json and is not working. Is there a way to fix this or do something similar since I don't want to be editing the configs on terminal. casperjs --config=config.json test.js My config.json file: { "load-images" : false } My test.js file: var casper = require('casper').create(); casper.start('http://www.example.com/', function(){ this.capture(

Casperjs and Failed to save screenshot with captureSelector

随声附和 提交于 2019-12-22 13:49:42
问题 I have such code : casper.thenOpen(url, function() { this.echo('Opening at ' + width); //give some time for the page to load casper.waitFor(function check() { return this.evaluate(function() { return document.querySelectorAll('#browse-packshots').length > 0; }); }, function then() { //set the viewport to the desired height and width this.viewport(width, height); //Set up two vars, one for the fullpage save, one for the actual viewport save var FPfilename = saveDir + '/fullpage-' + width + "

CasperJS/PhantomJS failing SSL handshakes on some sites even with --ssl-protocol=any

旧街凉风 提交于 2019-12-22 08:13:07
问题 I've had issues with CasperJS and SSL, but using --ssl-protocol=any has always fixed the problem, as referenced in this answer. In this case, I'm still having issues. I put this in the command line: casperjs --ssl-protocol=any --ignore-ssl-errors=true sanity.js This is sanity.js: var casper = require('casper').create({ verbose: true, logLevel: 'debug' }); casper.on("resource.error", function(resourceError){ console.log('Unable to load resource (#' + resourceError.id + 'URL:' + resourceError

Wait for an element to have a specific text with CasperJS

萝らか妹 提交于 2019-12-22 08:07:10
问题 I'm using CasperJS to read a certain web page. What I want to do is load a web page in CasperJS. Then, wait for a certain HTML element to have a specific text. So what I'd LIKE to do is this: var casper = require('casper').create(); casper.start('http://www.example.com/somepage', function() { this.echo('Home page opened'); }); // wait for text based on a CSS selector casper.waitForText('.someCssClass', 'dolor sit', function() { this.echo('found title!'); }); // when text is eventually found,

how can I click a link using CasperJS without knowing the css selector

拈花ヽ惹草 提交于 2019-12-22 06:58:13
问题 <a href="pss.exe?TRANSACTION=CGI_JUMP&SESSDATA=randomstuff&SKIN=default&LANG=en-US"> Change passwords </a> <a href="psk.exe?TRANSACTION=CGI_JUMP&SESSDATA=randomstuff&SKIN=default&LANG=en-US"> Unlock accounts </a> One link has a pss.exe and the other has psk.exe The InnerText is "Change Password" or "Unlock Accounts" so how can I click on the "Change Password" link. The A tag has no class or name or any easy way for me to use a css selector. 回答1: CSS selectors are pretty versatile. You can

What is the correct way to launch slimerjs in casperjs (with an absolute path)?

我的梦境 提交于 2019-12-22 06:44:41
问题 Well, i can launch slimerjs by specifying the path of the slimer.bat file : C:\bin\slimerjs\slimerjs.bat and then execute my file. But if i modify casperjs file (in bin\ ) and modify the default exec for slimer : 'env_varname': 'SLIMERJS_EXECUTABLE', 'default_exec' : 'C:\bin\slimerjs\slimerjs.bat' when i execute the casper command : casperjs --engine=slimerjs test.js It doesn't work, the path to slimerjs.bat seems to be ignored. I tried this too : https://github.com/laurentj/slimerjs/blob