Skip to content

Commit

Permalink
Add support for multiple account holders
Browse files Browse the repository at this point in the history
  • Loading branch information
ludufre committed Mar 12, 2022
1 parent a4feb0d commit 1e5122d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
17 changes: 17 additions & 0 deletions itauscraper.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,23 @@ const stepLogin = async (page, options) => {
await page.waitForTimeout(500)
await page.click('#btnLoginSubmit')

if(!!options.name){
console.log('Opening account holder page...');
await page.waitForTimeout(2000)
await stepAwaitRegularLoading(page)
await page.waitForSelector('ul.selecao-nome-titular', { visible: true })
console.log('Account holder page loaded.')

const names = await page.$$('ul.selecao-nome-titular a[role="button"]');
for (const name of names) {
const text = await page.evaluate(element => element.textContent, name);
if(text.toUpperCase() == options.name.toUpperCase()){
name.click();
console.log('Account holder selected.')
}
}
}

console.log('Opening password page...')
await page.waitForTimeout(2000)
await stepAwaitRegularLoading(page)
Expand Down
7 changes: 7 additions & 0 deletions run.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ const argv = require('yargs')
required: true,
type: 'number'
})
.option('name', {
alias: 'n',
describe: 'Itaú account holder name, format: Joao',
type: 'string'
})
.option('days', {
alias: 'd',
describe: 'Transaction log days',
Expand All @@ -44,6 +49,7 @@ const argv = require('yargs')
// Config
nconf.env({ lowerCase: true }).argv(argv)
const environment = nconf.get('node_env')
console.log(environment)
nconf.file(environment, './config/' + environment.toLowerCase() + '.json')
nconf.file('default', './config/default.json')

Expand All @@ -52,3 +58,4 @@ const options = nconf.get()
console.log('Starting using node environment: ' + environment)
// Run
itauscraper(options)

0 comments on commit 1e5122d

Please sign in to comment.