php curl获取html和js渲染 [英] php curl get html and js render

查看:71
本文介绍了php curl获取html和js渲染的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

php curl只获取html页面的源代码,而不执行js脚本.我需要在我的网站上获取所有已执行的javascript的源代码.我使用ajax,并且无法在页面中添加更多js,因为在加载另一个页面时脚本会保留.我找到了spiderMonkey,但无法解决我的问题.

php curl only get the source code of a html page without executing the js script. I need for my website to get the source code with all the javascript already executed. I use ajax and I can't add more js in the page because script stay when I load another page. I find spiderMonkey but it can't fix my problem.

php中是否有某些功能可以做到这一点?

Is there something in php which do that ?

谢谢

推荐答案

不,您不能.不是直接来自PHP.

No you can't. Not from PHP directly.

如果您可以控制服务器,则可以安装 phantomjs 并执行代码,因为它基本上为您提供了一个无头的浏览器,可以执行您想要的操作.

If you have control over the server you could install phantomjs and have it execute the code since it basically provides you with a headless browser that can do what you want.

这篇关于php curl获取html和js渲染的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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