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

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

问题描述

有可能获取带有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?

页面我需要得到使用一些编码和genereated内容,所以我想先运行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?

推荐答案

你可以做,但它比我想象的更多。 curl wget 都没有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

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

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