Use cron to start a Python script on a recurring schedule, and use Playwright inside that script to open the chosen Indian news page and save its screenshot. Cron handles the timing; Python and Playwright handle navigation, page readiness, capture scope, and the output file.
What you need before scheduling captures
- Python and a virtual environment for the account that will own the cron job.
- Playwright installed in that environment, with its browser runtime available to that account.
- The exact news-page URL, a writable absolute output path, and a decision about whether you need the visible viewport, the full page, or one element.
- A site-specific way to tell that the content you care about is ready. A completed navigation alone does not establish that client-rendered headlines have appeared.
Install Playwright in the environment you will use for the job, then install its Chromium browser runtime. The exact installation commands can vary by operating system and deployment, so follow the current Playwright Python installation instructions. Before adding cron, run the script manually as the same account that will own the crontab.
As an Amazon Associate I earn from qualifying purchases.
Write the Python capture script
This illustrative pattern opens a page, waits for the initial DOM to load, and saves a full-page PNG. Replace the URL and paths, and add a meaningful readiness check for the selected site before capturing. The example is not a tested recipe for a particular news website.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minutefrom pathlib import Path
from playwright.sync_api import sync_playwright
URL = "https://example.com/" # replace with the selected news page
OUTPUT = Path("/absolute/path/to/output/news-page.png")
OUTPUT.parent.mkdir(parents=True, exist_ok=True)
with sync_playwright() as p:
browser = p.chromium.launch()
try:
page = browser.new_page(viewport={"width": 1365, "height": 900})
page.goto(URL, wait_until="domcontentloaded", timeout=60_000)
# Add a site-specific readiness condition if the desired content
# appears after the initial document has loaded.
page.screenshot(path=str(OUTPUT), full_page=True)
finally:
browser.close()
Playwright’s documented screenshot method saves to a file; full_page=True captures the full scrollable page. See the Playwright Python screenshot documentation. The viewport, output location, readiness condition, browser choice, and capture scope should fit the page and archive you need.
#1 Best Overall
Choose what the image should contain
- Viewport: omit
full_page=Trueto capture the visible frame at the chosen viewport dimensions. This is useful for a consistent front-page snapshot. - Full page: set
full_page=Truewhen the entire scrollable document matters. It can produce a tall image and may include content far below the headlines. - One element: use a locator screenshot when you only need a specific component, such as a headline container:
page.locator("YOUR_CSS_SELECTOR").screenshot(path=str(OUTPUT)). Replace the selector with one that exists on the chosen site.
Make readiness specific to the page
wait_until="domcontentloaded" means the initial document has been parsed; it is not a guarantee that headlines, advertisements, or other client-rendered content have finished updating. If a stable headline container is available, wait for a locator that identifies it before taking the screenshot, for example page.locator("YOUR_CSS_SELECTOR").wait_for(state="visible", timeout=30_000). The selector and timeout are site-dependent. If the page has no reliable marker, choose and document a deliberate wait strategy, then inspect saved captures to confirm it is adequate; no single generic wait guarantees readiness across news sites.
Add the job to cron
A crontab entry has five schedule fields followed by the command: minute, hour, day of month, month, and day of week. The following example is hourly at minute zero, with output and errors appended to a log:
Rank #2
CRON_TZ=Asia/Kolkata
0 * * * * /absolute/path/to/venv/bin/python /absolute/path/to/capture.py >> /absolute/path/to/capture.log 2>&1
CRON_TZ is documented by Cronie, but not guaranteed for every cron implementation. Confirm the target host’s cron variant and timezone behavior before relying on it. The five-field schedule and other behavior described here are based on the Cronie crontab manual, whose details are implementation-specific.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Install and verify the entry
- Log in as the account that should own the scheduled task.
- Run the capture directly with the same interpreter and script paths that will appear in cron. Confirm it exits successfully and writes the expected image.
- Open that account’s user crontab with
crontab -e, add the schedule and command, and save it. Use the host’s documented procedure if it uses a different cron service or syntax. - After the next scheduled run, check the log and output file. Keep the log path writable by the owner, and monitor failures rather than assuming a recurring entry succeeded.
Read the schedule carefully
Cronie checks entries each minute. In Cronie’s implementation, when both day-of-month and day-of-week are restricted, a job can run when either field matches rather than requiring both. Cronie also documents daylight-saving behavior: a nonexistent local time does not match, while a repeated local time can run twice. These are not universal guarantees for every cron daemon. If duplicate or missed captures matter, check the installed implementation’s manual and make the capture process safe to rerun.
Keep the capture predictable and diagnosable
Use explicit paths and the intended account
Cron jobs do not necessarily inherit the interactive shell environment you use at a terminal. Cronie documents that it sets values such as SHELL, LOGNAME, and HOME from the crontab owner’s account information, and runs commands through the configured shell. Use absolute paths for Python, the script, and output; verify the destination is writable by that account; and avoid relying on shell startup files to activate a virtual environment.
Choose locale, timezone, and viewport deliberately
The timezone used to schedule the cron job is separate from the timezone and locale presented to the browser. Playwright browser contexts can emulate locale and timezone, as well as device and viewport settings; set them deliberately if they affect what the page displays. See Playwright’s emulation documentation. A schedule in Indian Standard Time does not by itself make the browser render dates, language, or location as Indian.
Plan for changing pages and imperfect runs
- News pages change between runs. Keep the URL, capture time, and output naming scheme clear enough to identify each image in your archive.
- A site may be unavailable, slow, or render differently on a later run. Log errors and retain a useful process exit status so failures are visible.
- Full-page captures can be much taller than viewport captures. Check that the resulting size and destination storage suit your retention plan.
- Do not treat a screenshot as proof that every headline was captured correctly. Review representative outputs and revisit the readiness condition when the site layout changes.
Troubleshooting common cron and Playwright failures
| Symptom | Likely cause | What to check or change |
|---|---|---|
| No image appears | The job may not have run, or the script may be writing somewhere unexpected. | Check the cron service and account crontab, inspect the redirected log, and confirm the script uses an absolute output path with a writable parent directory. |
python or a module cannot be found |
Cron is using a different PATH or Python environment from your interactive shell. | Use the virtual environment’s absolute Python executable in the crontab command and install Playwright in that environment. |
| Browser launch fails | The browser runtime may not be installed or available to the scheduled account. | Install the required Playwright browser runtime according to the official installation instructions, then retry manually as the job owner. |
| The screenshot is blank or misses headlines | Navigation may have completed before the content of interest rendered, or the selected locator may not match. | Inspect the page and screenshot manually, verify any CSS selector, and wait for a site-specific visible element before capture. |
| The schedule runs at an unexpected local time | The host’s cron implementation may not support CRON_TZ, or the host and intended schedule use different timezones. |
Confirm the cron variant and its timezone rules. Do not assume Cronie’s extension exists on another daemon. |
| A scheduled time is skipped or a capture appears twice around a clock change | Daylight-saving transitions can affect civil-time schedules, depending on the cron implementation and timezone. | Check the host manual; Cronie’s documented behavior omits nonexistent local times and can repeat a matching time. |
| The job works in a terminal but not from cron | The job may depend on an interactive environment, relative paths, or permissions unavailable to cron. | Run the exact command under the crontab owner, use absolute paths, check file permissions, and redirect standard output and errors to a log. |
Or skip the browser setup
ScreenshotNeo can return a screenshot or PDF from one GET request. Its clean-shot steps accept cookie or consent banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server includes tools for AI agents, and 1,000 shots per month are free without a card; paid plans start at $5 for 3,000 shots.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com/ -o shot.webp
See the ScreenshotNeo API documentation for request options. For a recurring schedule, place the request in a Python script and schedule that script with cron as above; the API call handles the screenshot capture, not the schedule. Sign up for 1,000 free screenshots a month with no card.
Frequently Asked Questions
Can cron take the screenshot by itself?
No. Cron starts the command on its schedule; the Python script and Playwright perform navigation and capture.
Best Value
Does the hourly example run at the top of every hour in every timezone?
It runs at minute zero according to the cron daemon’s applicable schedule timezone. The example’s CRON_TZ setting is a Cronie extension, so check the host implementation.
Should I use a viewport, full-page, or element screenshot for a news site?
Use a viewport for a consistent visible frame, full-page for the scrollable document, or a locator screenshot for a specific content block.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




