Advertisement
Guest User

Untitled

a guest
Mar 31st, 2015
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var casper = require('casper').create()
  2.   , system = require('system');
  3.  
  4. var marketId = casper.cli.options['market-id'];
  5.  
  6. casper.start('http://market.yandex.ru/shop-info.xml?shop_id='+marketId, function() {
  7.     this.capture('page.png');
  8.     if( this.exists('img.image.form__captcha') ) {
  9.         this.captureSelector('captcha.png', 'img.image.form__captcha');
  10.         system.stdout.write('введите капчу: ');
  11.         var captcha = system.stdin.readLine();
  12.         this.sendKeys('#rep', captcha);
  13.         this.fill('form[action="/checkcaptcha"]', { rep: captcha }, true);
  14.     }  
  15. });
  16.  
  17. casper.then(function() {
  18.     this.waitForSelector('.b-old-shop-info__table', function() {
  19.         this.capture('page.png');
  20.         this.echo(this.evaluate(function() {
  21.             return document.querySelector('.b-old-shop-info__table tr:last-child td:last-child').textContent;
  22.         }));
  23.     });
  24. });
  25.  
  26. casper.run();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement