我已经在我的 Linux 机器(Ubuntu)上成功安装了 Spidermonkey JS 引擎。基本上我的目标是让它执行 Ajax (js) 脚本并将结果返回给我的 Python 脚本。我基本上是在尝试构建一个好的 OO 网络爬虫。但我很难让所有这些工作。
我现在可以在终端中键入 JS 时开始执行 Javascript。我一直在谷歌搜索,在 Stackoverflow 上找到了这个小片段:
import urllib2
import spidermonkey
js = spidermonkey.Runtime()
js_ctx = js.new_context()
script = urllib2.urlopen('http://etherhack.co.uk/hashing/whirlpool/js/whirlpool.js').read()
js_ctx.eval_script(script)
js_ctx.eval_script('var s="abc"')
js_ctx.eval_script('print(HexWhirpool(s))')
但它无法运行,并出现无法找到模块 Spidermonkey 的错误。
我现在有点迷路了。有谁能帮忙吗?