Skip to content

Instantly share code, notes, and snippets.

@dalleng
Last active March 22, 2024 13:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dalleng/493747edc3950a63c178 to your computer and use it in GitHub Desktop.
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
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