Phantomjs 上的 javascriptEnabled 问题
我正在使用 phantomjs 从网站上抓取一些数据。为了加快加载速度,我通过这样做禁用了网页上js的执行:
page.settings.javascriptEnabled = false;
但这会导致问题——它使 page.evaluate(somefunc.toString())
返回 null
无论函数应该返回什么。 如果我将 js 设置默认设置为 true,则 page.evaluate()
将再次工作。
我应该如何解决这个问题? 谢谢
I was using phantomjs to scrape some data from a website. In order to speed up the loading I disabled the execution of js on the webpage by doing this:
page.settings.javascriptEnabled = false;
but this causes the problem--it makes page.evaluate(somefunc.toString())
return null
no matter what the function should return.
If I keep the js setting default to true the page.evaluate()
would work again.
How should I work around this?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一般来说,不要这样做。
但是,如果您确实需要,您可以保持JavaScript启用,但阻止加载外部.js文件。例如:
In general, don't do that.
However, if you really need that, you may keep JavaScript enabled, but block loading external .js files. E.g.: