How to intercept *NON* http/s requests in puppeteer

Viewed 93

I'm trying to scrape the following html:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>click.com.cn</title>
<script >
window.location.href='weixin://dl/business/?t=111111'
</script>
</head>
<body>
</body>
</html>

since weixin is a custom protocol the browser cannot navigate to this website.

However it also makes the puppeteer page to get stuck on screenshot request .

I have tried to intercept this weixin:// request but have noticed that the request interceptor intercepts only http/s requests

my code :

  await page.setRequestInterception(true);
  page.on("request", async (request: Request) => {
   const url = request.url();
   // request.abort etc...
  }

Is there an option in puppeteer or in Chrome DevTools Protocol to intercept all kind of protocols .

Also tried to override the window.location.href property but it failed.

0 Answers
Related