问题描述
我需要在使用 puppeteer 导航到“chrome pdf 视图”时下载 pdf。 this 是我用来测试这个的测试链接。
我正在尝试从响应正文中获取 pdf 缓冲区
page.on('response',async response => {
console.log('in response');
if (response.url().includes('.pdf')) {
console.log(await response.text())
}
})
await page.goto('https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf')
但只给我pdf的预览数据
我也试过 response.buffer() 但这也给了我预览数据。但我需要实际 pdf 文件数据的缓冲区。
当我在 postman 中点击 pdf 链接时,我确实在正文中看到了 pdf 数据,所以我不明白为什么我无法在 puppeteer 响应中得到它。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)