Puppeteer登录页面。评估 [英] Puppeteer log inside page.evaluate

查看:94
本文介绍了Puppeteer登录页面。评估的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何在page.elogate中调整内容,将其传递给节点并在>评估页面时使用



<我真的想将page.evaluate的进度记录到控制台并向用户显示一些结果。

解决方案

**已更新,适用于puppeteer v1.4.x



如果你想要的只是记录页面的进度。评估到控制台,那么只需

  const page =等待browser.newPage(); 

page.on('console',consoleObj => console.log(consoleObj.text()));

并在<$中使用 console.log c $ c> page.evaluate 像往常一样,不再需要依赖项。



另见这个很好的调整,从日志中删除多个烦人的警告。


How can I console.log something inside the page.evaluate, passing it to node and using it during the evaluation of the page?

I actually want to log the progress of the page.evaluate to the console and show some results to the user.

解决方案

**Updated to work with puppeteer v1.4.x

If all you want is to "log the progress of the page.evaluate to the console", then just

const page = await browser.newPage();

page.on('console', consoleObj => console.log(consoleObj.text()));

And use console.log in page.evaluate as usual, no more dependencies are required.

Also see this nice tweak to remove multiple annoying warnings from log.

这篇关于Puppeteer登录页面。评估的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆