我如何保留网站的标头并使用puppeteer发出另一个请求

时间:2020-06-14 20:10:12

标签: node.js bots puppeteer

我正在使用puppeteer-stealth并尝试在发出请求时保持与浏览器窗口相同的标题。下面的代码在新选项卡中打开,并且没有相同的标题。预先谢谢你

await this.page.setRequestInterception(true);
    // 2. Intercept request
    this.page.once("request", async (request) => {
      // 3. Make request using Node.js
      const response = await got(request.url(), {
        // HTTP proxy.
        //agent: new HttpProxyAgent("http://127.0.0.1:3000"),
        body,
        method: POST,
        json: true,
        retry: 0,
        throwHttpErrors: false,
      });
      // 4. Return response to Chrome
      await request.respond({
        body: response.body,
        headers: response.headers,
        status: response.statusCode,
      });
    });

    interceptedRequest.continue(data);

0 个答案:

没有答案