使用 curl 执行 javascript 后获取源代码 [英] get sourcecode after javascript execution with curl

查看:32
本文介绍了使用 curl 执行 javascript 后获取源代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用 curl 获取网页的 html 源代码并在其上运行 javascript 解释器,以便获得生成的内容?

Is it possible to get the html source code of a webpage with curl and the run a javascript interpreter over it, so i get the generated content?

我需要获取的页面在那里使用了一些编码和生成的内容,所以我想首先运行 javascript 来获取转义和生成的内容......或者我是否需要对 javascript 进行正则表达式并编译"javascript我自己的?喜欢

The Page i need to get uses some encoded and genereated content in there so i want to first run the javascript to get the escaped and generated content... or do i need to regex the javascript and "compile" the javascript on my own? Like

curl <myurl> | perl -ne 'm/unescape((.*))/; print "$1"' | <now to something with that>

我知道 curl 中没有 javascript 引擎,但我可以调用另一个脚本/程序来完成这项工作吗?

i known there is no javascript engine in curl but can i just call another script / programm to do the job?

推荐答案

你可以做到,但它比我想象的要复杂得多.curlwget 都没有 Javascript 引擎,所以你需要有一个引擎.

You can do it, but it's more involved than I think you realize. Neither curl nor wget have Javascript engines, so you'll need something that has one.

我会先看看 PhantomJS.

这篇关于使用 curl 执行 javascript 后获取源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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