xxxxxxxxxx
import pyautogui
# Capture and save the screenshot
pyautogui.screenshot('screenshot.png')
xxxxxxxxxx
const puppeteer = require('puppeteer');
(async () => {
// Launch a headless Chrome browser instance
const browser = await puppeteer.launch();
// Create a new page
const page = await browser.newPage();
// Set the viewport size based on your requirements
await page.setViewport({ width: 1280, height: 800 });
// Navigate to the page you want to capture
await page.goto('https://www.example.com');
// Scroll the window to the bottom to capture the entire content
await page.evaluate(() => {
window.scrollTo(0, document.body.scrollHeight);
});
// Wait for a small delay to let the content settle
await page.waitForTimeout(1000);
// Capture a screenshot of the entire scrolling window
await page.screenshot({ path: 'scrolling_screenshot.png', fullPage: true });
// Close the browser instance
await browser.close();
})();
xxxxxxxxxx
import pyautogui
# Take a screenshot of the entire screen
screenshot = pyautogui.screenshot()
screenshot.save('screenshot.png')
# Take a screenshot of a specific region
# Define the region coordinates
x = 100
y = 100
width = 300
height = 200
# Capture the region screenshot
region_screenshot = pyautogui.screenshot(region=(x, y, width, height))
region_screenshot.save('region_screenshot.png')