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

Using Android Volley to post an array to PHP -

python - How to add an model instance to a django queryset? -

angularjs - No 'Access-Control-Allow-Origin' error from local domain to public API -