I want to block(abort) all requests to video resources, how can I achieve it with puppeteer?
I see there is an example in the documentation:
An example of a naïve request interceptor that aborts all image requests:
page.on('request', interceptedRequest => {
if (interceptedRequest.url().endsWith('.png') || interceptedRequest.url().endsWith('.jpg'))
interceptedRequest.abort();
else
interceptedRequest.continue();
});
But I can't seem to find an example on how to block videos.
Only the response headers says the content-type
and I don't want to waste the bandwidth for vain.
I want to block(abort) all requests to video resources, how can I achieve it with puppeteer?
I see there is an example in the documentation:
An example of a naïve request interceptor that aborts all image requests:
page.on('request', interceptedRequest => {
if (interceptedRequest.url().endsWith('.png') || interceptedRequest.url().endsWith('.jpg'))
interceptedRequest.abort();
else
interceptedRequest.continue();
});
But I can't seem to find an example on how to block videos.
Only the response headers says the content-type
and I don't want to waste the bandwidth for vain.
1 Answer
Reset to default 11Great question, had the same issue myself.