Skip to content

Commit

Permalink
fix: Fixed QRCode reader
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed Nov 19, 2020
1 parent b0aacab commit 247fe17
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/api/helpers/scrape-img-qr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
import { Page } from 'puppeteer';
export async function scrapeImg(page: Page): Promise<any> {
var result = await page.evaluate(() => {
const selectorimg = document.querySelector('canvas');
let selectorUrl = document.querySelector('._1QMFu');
const selectorImg = document.querySelector('canvas');
const selectorUrl = selectorImg.closest('[data-ref]');

if (selectorimg != null && selectorUrl != null) {
if (selectorImg != null && selectorUrl != null) {
let data = {
img: selectorimg.toDataURL(),
img: selectorImg.toDataURL(),
url: selectorUrl.getAttribute('data-ref'),
};
return data;
Expand Down
17 changes: 11 additions & 6 deletions src/api/helpers/scrape-img-reload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,27 @@ MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
import { Page } from 'puppeteer';
export async function scrapeImgReload(page: Page, url): Promise<any> {
let click = await page.evaluate(() => {
let bt = document.querySelector('._3IKPF');
if (bt != null) {
const selectorImg = document.querySelector('canvas');
const selectorUrl = selectorImg.closest('[data-ref]');
const buttonReload = selectorUrl.querySelector(
'[role="button"]'
) as HTMLButtonElement;
if (buttonReload != null) {
buttonReload.click();
return true;
} else {
return void 0;
}
});
if (click != undefined) {
page.click('._3IKPF');
await page.waitForNavigation();
console.log('Load button pressed');
}
var result = await page.evaluate(() => {
let selector = document.querySelector('._1QMFu');
if (selector != null) {
return selector.getAttribute('data-ref');
const selectorImg = document.querySelector('canvas');
const selectorUrl = selectorImg.closest('[data-ref]');
if (selectorUrl != null) {
return selectorUrl.getAttribute('data-ref');
} else {
return void 0;
}
Expand Down

0 comments on commit 247fe17

Please sign in to comment.