Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Bulk website screenshots in Python with Playwright: full-page, mobile, PDF and no cookie banners

Описание и применение

Автоматизированный скрипт на Python с Playwright позволяет быстро делать полноэкранные и мобильные скриншоты сайтов, скрывая баннеры cookie и загружая ленивые изображения, а также экспортировать в PNG или PDF.

Задача

Capturing hundreds of website screenshots that look correct is difficult due to cookie banners, lazy-loaded images, large page sizes, and sites that never reach network idle.

Результат

The script successfully captured screenshots from six diverse sites, handling cookie banners, lazy-loading, and large page heights, producing clean PNG or PDF files.

Рабочий процесс

  • Install Playwright and Chromium
  • Create a list of URLs
  • Run the script with desired flags (e.g., --mobile --full --pdf --workers 4)
  • Script launches browsers, navigates to each URL, waits for load, injects CSS to hide cookie banners, scrolls to trigger lazy images, captures full-page or viewport, outputs PNG or PDF
  • Collects screenshots in the specified output directory

Доказательства

Taking one screenshot with Playwright is a two-liner. Taking a few hundred that actually look right is where it gets fiddly: cookie banners cover half the page, lazy-loaded images come out blank, news homepages produce 60,000-pixel PNGs, and some sites never reach "network idle".

Источник

Here's the script I ended up with, plus what happened when I ran it on six sites on October 21, 2026 (example.com, python.org, crawlee.dev, MDN, BBC and the Guardian).

Источник

  • Дата записи: 2026-10-21T19:26:10.704Z