forked from unconv/gpt4v-browsing
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
25762fc
commit 124a9d6
Showing
3 changed files
with
44 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const puppeteer = require('puppeteer-extra'); | ||
const StealthPlugin = require('puppeteer-extra-plugin-stealth'); | ||
puppeteer.use(StealthPlugin()); | ||
|
||
const url = process.argv[2]; | ||
const pageLoadTimeout = 30000; // 30 seconds for page load | ||
const extraWaitTime = 5000; // 5 seconds extra wait after page load | ||
|
||
(async () => { | ||
try { | ||
const browser = await puppeteer.launch({ | ||
headless: true, // Set to false to see the browser | ||
args: ['--no-sandbox', '--disable-setuid-sandbox'], // Added for better stability in different environments | ||
}); | ||
|
||
const page = await browser.newPage(); | ||
|
||
await page.setViewport({ | ||
width: 1200, | ||
height: 1200, | ||
deviceScaleFactor: 1, | ||
}); | ||
|
||
await page.goto(url, { | ||
waitUntil: "networkidle0", | ||
timeout: pageLoadTimeout, | ||
}); | ||
|
||
// Wait for additional time if needed, then take the screenshot | ||
await page.waitForTimeout(extraWaitTime); | ||
|
||
await page.screenshot({ | ||
path: "screenshot.jpg", | ||
fullPage: true, | ||
}); | ||
|
||
console.log("Screenshot saved as 'screenshot.jpg'"); | ||
} catch (error) { | ||
console.error("An error occurred:", error); | ||
} finally { | ||
await browser.close(); | ||
} | ||
})(); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters