Last active
March 22, 2024 13:20
-
-
Save dalleng/493747edc3950a63c178 to your computer and use it in GitHub Desktop.
Ejemplo para extraer datos básicos del contribuyente de marangatu usando casperjs. Uso: casperjs datosBasicosContribuyente.js --ruc=ruc --password=password
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var casper = require('casper').create({ | |
clientScripts: ['jquery.js'], | |
}); | |
var data = {}; | |
var ruc = casper.cli.get('ruc'); | |
var password = casper.cli.get('password'); | |
casper.start('https://marangatu.set.gov.py/eset/').thenEvaluate(function login(ruc, password) { | |
$('#usuarioId').val(ruc); | |
$('input[name=j_password]').val(password); | |
$('form[name=logonForm]').submit(); | |
}, ruc, password); | |
casper.then(function goToProfile() { | |
this.echo("Abriendo popup de registro unico"); | |
this.clickLabel('CONSULTAR REGISTRO UNICO', 'td'); | |
}); | |
casper.waitForPopup(/.*datosBasicosContribuyente.*$/, function() { | |
this.echo("Popup listo"); | |
}); | |
casper.withPopup(/.*datosBasicosContribuyente.*$/, function getProfileData() { | |
data.ruc = this.getElementAttribute('#ruc', 'value'); | |
data.dv = this.getElementAttribute('#dv', 'value'); | |
data.contributorType = this.getElementAttribute('#tipoContribuyente', 'value'); | |
data.contributorCategory = this.getElementAttribute('#categoriaContribuyente', 'value'); | |
this.echo('Datos basicos'); | |
this.echo(JSON.stringify(data)); | |
}); | |
casper.thenOpen('https://marangatu.set.gov.py/eset/logout.do', function logout() { | |
this.echo('Cerrando sesion'); | |
}); | |
casper.run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment