Optimizing Traffic
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)await page.route('**/*', (route) => {
const request = route.request();
const type = request.resourceType();
if (['image', 'stylesheet', 'media', 'font'].includes(type)) {
return route.abort();
}
return route.continue();
});Last updated
Was this helpful?

