Skip to content

Commit

Permalink
feat: page timeout (#22)
Browse files Browse the repository at this point in the history
Co-authored-by: Jef LeCompte <jeffreylec@gmail.com>
  • Loading branch information
IonCaza and jef committed Sep 18, 2020
1 parent 7d7bd18 commit 643045c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -3,3 +3,4 @@ build/
node_modules/

.env
success-*.png
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -67,6 +67,7 @@ First, you're going to need to copy the `.env.example` to `.env`. The current op
| `EMAIL_USERNAME` | Gmail address; e.g. `jensen.robbed.us@gmail.com` |
| `EMAIL_PASSWORD` | Gmail password; see below if you have MFA |
| `STORES` | List of [stores](#Supported-stores) you want to be scraped; optional, default: `nvidia` |
| `PAGE_TIMEOUT` | Navigation Timeout in milliseconds (0 for infinite, 60000 for 1 minute); optional, default: `0` |

> :point_right: If you have multi-factor authentication (MFA), you will need to create an [app password](https://myaccount.google.com/apppasswords) and use this instead of your Gmail password.
Expand Down
3 changes: 2 additions & 1 deletion src/config.ts
Expand Up @@ -16,7 +16,8 @@ const notifications = {
const page = {
height: 1920,
userAgent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36',
width: 1080
width: 1080,
navigationTimeout: Number(process.env.PAGE_TIMEOUT) ?? 30000
};

const stores = process.env.STORES ?? 'nvidia';
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Expand Up @@ -40,6 +40,7 @@ async function lookup(store: Store) {
for (const link of store.links) {
const browser = await puppeteer.launch();
const page = await browser.newPage();
page.setDefaultNavigationTimeout(Config.page.navigationTimeout);
await page.setUserAgent(Config.page.userAgent);
await page.setViewport({
height: Config.page.height,
Expand Down

0 comments on commit 643045c

Please sign in to comment.