Skip to content

Commit

Permalink
more headers
Browse files Browse the repository at this point in the history
  • Loading branch information
rhyek committed Jun 12, 2024
1 parent 08eff2c commit e5ab3a3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
19 changes: 18 additions & 1 deletion projects/scrape-txs/src/lib/bac-gt/scrape.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import dayjs from 'dayjs';
import customParseFormat from 'dayjs/plugin/customParseFormat.js';
import { type Page } from 'playwright';
import { type BrowserContext, type Page } from 'playwright';
import { isMatching } from 'ts-pattern';
import { db, type DB, type InsertObject } from '../db';
import { waitRandomMs } from '../utils';
Expand Down Expand Up @@ -33,6 +33,22 @@ export async function bacGtScrape({
);
const createTxs: InsertObject<DB, 'bank_txs'>[] = [];
const deleteTxIds: string[] = [];

await page.setExtraHTTPHeaders({
Accept:
'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
'Accept-Encoding': 'gzip, deflate, br, zstd',
'Accept-Language': 'en-US,en;q=0.9',
'Sec-Ch-Ua':
'"Google Chrome";v="125", "Chromium";v="125", "Not.A/Brand";v="24"',
'Sec-Ch-Ua-Mobile': '?0',
'Sec-Ch-Ua-Platform': '"macOS"',
'Sec-Fetch-Dest': 'document',
'Sec-Fetch-Mode': 'navigate',
'Sec-Fetch-Site': 'none',
'Sec-Fetch-User': '?1',
'Upgrade-Insecure-Requests': '1',
});
await page.goto('https://www.baccredomatic.com/');
await waitRandomMs();
await page
Expand Down Expand Up @@ -64,6 +80,7 @@ export async function bacGtScrape({
'https://www1.sucursalelectronica.com/ebac/module/consolidatedQuery/consolidatedQuery.go'
);
if (account.type === 'checking') {
await waitRandomMs();
await page
.locator('.bel-card')
.filter({ has: page.getByText('Cuentas bancarias') })
Expand Down
3 changes: 1 addition & 2 deletions projects/scrape-txs/src/lib/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export async function run(months: dayjs.Dayjs[]) {
});
const context = await browser.newContext({
userAgent:
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36',
});
if (isLambda()) {
await context.tracing.start({
Expand All @@ -42,7 +42,6 @@ export async function run(months: dayjs.Dayjs[]) {
let createTxs: InsertObject<DB, 'bank_txs'>[];
let deleteTxIds: string[];
try {
console.log('beginning');
const result = await (async () => {
if (process.env.BANK_KEY === 'bancoIndustrialGt') {
return await bancoIndustrialScrape({
Expand Down

0 comments on commit e5ab3a3

Please sign in to comment.