最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Block video requests on puppeteer - Stack Overflow

programmeradmin0浏览0评论

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.

Share Improve this question asked Apr 30, 2019 at 20:00 gdorongdoron 150k59 gold badges302 silver badges371 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 11

Great question, had the same issue myself.

发布评论

评论列表(0)

  1. 暂无评论