Documentation has been updated: see help center and changelog in one place.

Optimizing Traffic

Your automation scripts often download unnecessary resources such as images, stylesheets, fonts, and other media files. These files consume bandwidth and can slow down your scraping operations.

You can block these unnecessary resources from loading entirely. By intercepting network requests and selectively blocking media files, you can focus only on the data you actually need.

These code snippets works with both Playwright and Puppeteer to block media resources before they're downloaded:

async def block_resources(route):
    request = route.request
    resource_type = request.resource_type
    if resource_type in ['image', 'stylesheet', 'media', 'font']:
        await route.abort()
    else:
        await route.continue_()
await page.route('**/*', block_resources)

Last updated

Was this helpful?