Skip to content

Commit

Permalink
Merge ca4cee2 into 08633a7
Browse files Browse the repository at this point in the history
  • Loading branch information
Menighin committed Aug 18, 2020
2 parents 08633a7 + ca4cee2 commit a6434d2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cei-crawler",
"version": "1.2.0",
"version": "1.3.0",
"description": "Crawler para pegar dados do Canal Eletronico do Investidor",
"main": "src/app.js",
"repository": {
Expand All @@ -24,7 +24,7 @@
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.9.6",
"puppeteer": "^2.1.1"
"puppeteer": "^2.0.0"
},
"devDependencies": {
"@babel/core": "^7.9.0",
Expand Down
1 change: 1 addition & 0 deletions src/lib/DividendsCrawler.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class DividendsCrawler {
console.log(`Selecting account ${account}`);

await page.select(PAGE.SELECT_ACCOUNT, account);
await page.waitForSelector(PAGE.SUBMIT_BUTTON);
await page.click(PAGE.SUBMIT_BUTTON);

// Wait for table to load or give error / alert
Expand Down
7 changes: 6 additions & 1 deletion src/lib/StockHistoryCrawler.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ class StockHistoryCrawler {
console.log(`Selecting account ${account}`);

await page.select(PAGE.SELECT_ACCOUNT, account);
await page.waitForSelector(PAGE.SUBMIT_BUTTON);
await page.click(PAGE.SUBMIT_BUTTON);

// Wait for table to load or give error / alert
Expand Down Expand Up @@ -228,7 +229,11 @@ class StockHistoryCrawler {

/* istanbul ignore next */
const dataPromise = await page.evaluateHandle((select, headers) => {
const rows = document.querySelector(select).rows;

const tBody = document.querySelector(select);
if (tBody === null || tBody === undefined) return [];
const rows = tBody.rows;

return Array.from(rows)
.map(tr => Array.from(tr.cells).reduce((p, c, i) => {
p[headers[i]] = c.innerText;
Expand Down
1 change: 1 addition & 0 deletions src/lib/WalletCrawler.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class WalletCrawler {
console.log(`Selecting account ${account}`);

await page.select(PAGE.SELECT_ACCOUNT, account);
await page.waitForSelector(PAGE.SUBMIT_BUTTON);
await page.click(PAGE.SUBMIT_BUTTON);

// Wait for table to load or give error / alert
Expand Down

0 comments on commit a6434d2

Please sign in to comment.