web scraping - How to click Logout as finalizer in CasperJS -



web scraping - How to click Logout as finalizer in CasperJS -

i creating web scraper (in casperjs using javascript) needs login authentication. need click logout link in end of script when process throws error, such non-existent element might occurs while in trial-and-error development. behavior similar java's finally {} block.

this behavior required since web allows single session per user. if don't click logout, next scraper invocation must wait 5 minutes expire previous session not good.

where should set logout click?

you can set casper.options.exitonerror property false allow script go on execute execute logout click.

var casper = require('casper').create({ exitonerror: false, });

or

casper.options.exitonerror = false;

this works in phantomjs 1.x, because phantomjs 2 doesn't throw error when selector cannot found. casperjs stops in case.

web-scraping phantomjs casperjs

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -