我有这个基本的帖子请求:
(async () => {
// Create browser instance, and give it a first tab
const browser = await puppeteer.launch({headless: false});
const page = await browser.newPage();
// Allows you to intercept a request; must appear before
// your first page.goto()
await page.setRequestInterception(true);
// Request intercept handler... will be triggered with
// each page.goto() statement
page.on('request', interceptedRequest => {
// Here, is where you change the request method and
// add your post data
var data = {
'method': 'POST',
'postData': …Run Code Online (Sandbox Code Playgroud) 我正在尝试获取所有请求标头以正确检查请求,但它只返回像 User-Agent 和 Origin 这样的标头,而原始请求包含更多标头。
有没有办法实际获取所有标题?
作为参考,这里是代码:
const puppeteer = require('puppeteer');
const browser = await puppeteer.launch({
headless: false
});
const page = await browser.newPage();
page.on('request', req => {
console.log(req.headers());
});
await page.goto('https://reddit.com');
Run Code Online (Sandbox Code Playgroud)
提前致谢,iLinked