admin管理员组

文章数量:1287636

I am using puppeteer to load a web page.

const browser = await puppeteer.launch({ headless: true });
  const page = await browser.newPage();
  await page.setRequestInterception(true);
  page.on('request', (request) => {
    console.log(request.url())
    request.continue();
    ...
  }
}
await page.goto(
    '',
    { waitUntil: 'networkidle2' },
  );

I set the request interception to true and log all requests urls. The requests I logged is a lot less than the requests when I load the url in chrome browser. At least there is one request which can be found in chrome dev tool console but not show in above code.

I wonder how I can log all requests?

I am using puppeteer to load a web page.

const browser = await puppeteer.launch({ headless: true });
  const page = await browser.newPage();
  await page.setRequestInterception(true);
  page.on('request', (request) => {
    console.log(request.url())
    request.continue();
    ...
  }
}
await page.goto(
    'https://www.onthehouse..au/property-for-rent/vic/aspendale-gardens-3195',
    { waitUntil: 'networkidle2' },
  );

I set the request interception to true and log all requests urls. The requests I logged is a lot less than the requests when I load the url in chrome browser. At least there is one request https://www.onthehouse..au/odin/api/positeSearch which can be found in chrome dev tool console but not show in above code.

I wonder how I can log all requests?

Share Improve this question edited Jun 12, 2020 at 12:58 reymon359 1,3302 gold badges18 silver badges37 bronze badges asked Jun 12, 2020 at 6:20 Joey Yi ZhaoJoey Yi Zhao 42.6k87 gold badges352 silver badges657 bronze badges 3
  • Isn't your Chrome DevTools Network records some 3rd party requests (e.g. Chrome addons) as well? I pared your script's requests and the page's network traffic in Chrome and for me they match in 100%. I see no more requests in Chrome. Edit: Nevermind, I get the "Access Denied" page, so I am unable to tell

    本文标签: javascriptHow can I get all xhr calls in puppeteerStack Overflow