admin管理员组文章数量:1279015
I am working with JS+Puppeteer and I'm trying to make a script that can add items to cart. The website will often crash due to high traffic, so instead of relying on clicking, I want the script to send the item info directly to the backend. Once it does that, it will continue to do things. The add-to-cart link is different from the website's link.
For example, the website is abc.shop, and the backend API address is abc.shop/api/... I want to send a JSON continuing the item data to the api address.
Is it possible to send a POST request using puppeteer to a different address, and if so, how?
I am working with JS+Puppeteer and I'm trying to make a script that can add items to cart. The website will often crash due to high traffic, so instead of relying on clicking, I want the script to send the item info directly to the backend. Once it does that, it will continue to do things. The add-to-cart link is different from the website's link.
For example, the website is abc.shop, and the backend API address is abc.shop/api/... I want to send a JSON continuing the item data to the api address.
Is it possible to send a POST request using puppeteer to a different address, and if so, how?
Share Improve this question asked Oct 2, 2020 at 23:46 Arthur XuArthur Xu 311 silver badge2 bronze badges1 Answer
Reset to default 11You can use page.evaluate
to send a post request using fetch api.
await page.evaluate(() => {
return fetch('url', {method: 'POST', body: 'test' }).then(res => res.json());
});
https://pptr.dev/#?product=Puppeteer&version=v3.3.0&show=api-pageevaluatepagefunction-args
本文标签: javascriptSend POST request in puppeteerStack Overflow
版权声明:本文标题:javascript - Send POST request in puppeteer - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741251858a2365940.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论