Skip to content

Commit

Permalink
all headers again
Browse files Browse the repository at this point in the history
  • Loading branch information
rhyek committed Jun 12, 2024
1 parent ccc734f commit 756caaf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 24 deletions.
22 changes: 11 additions & 11 deletions projects/scrape-txs/src/lib/bac-gt/scrape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ export async function bacGtScrape({
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:
'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"',
Expand All @@ -49,14 +49,14 @@ export async function bacGtScrape({
'Sec-Fetch-User': '?1',
'Upgrade-Insecure-Requests': '1',
});
await page.route('https://www.baccredomatic.com/', async (route) => {
const headers = Object.assign({}, route.request().headers(), {
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',
});
await route.continue({ headers });
});
// await page.route('https://www.baccredomatic.com/', async (route) => {
// const headers = Object.assign({}, route.request().headers(), {
// 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',
// });
// await route.continue({ headers });
// });
await page.goto('https://www.baccredomatic.com/');
await waitRandomMs();
await page
Expand Down
23 changes: 10 additions & 13 deletions projects/scrape-txs/src/lib/run.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PutObjectCommand, S3Client } from '@aws-sdk/client-s3';
import type dayjs from 'dayjs';
import fs from 'node:fs/promises';
import { chromium, type Browser } from 'playwright';
import { chromium } from 'playwright';
import lambdaChromium from '@sparticuz/chromium';
import { z } from 'zod';
import { bacGtScrape } from './bac-gt/scrape';
Expand All @@ -19,18 +19,15 @@ export async function run(months: dayjs.Dayjs[]) {
const config = configSchema.parse(configJson);
z.enum(['bancoIndustrialGt', 'bacGt'] as const).parse(process.env.BANK_KEY);

// const browser = isLambda()
// ? ((await chromium.launch({
// args: lambdaChromium.args,
// executablePath: await lambdaChromium.executablePath(),
// headless: true,
// })) as Browser)
// : await chromium.launch({
// headless: false,
// });
const browser = await chromium.launch({
headless: false,
});
const browser = isLambda()
? await chromium.launch({
args: lambdaChromium.args,
executablePath: await lambdaChromium.executablePath(),
headless: true,
})
: await chromium.launch({
headless: false,
});
const context = await browser.newContext({
userAgent:
'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',
Expand Down

0 comments on commit 756caaf

Please sign in to comment.