【问题标题】:How can I execute a .js file with python?如何使用 python 执行 .js 文件?
【发布时间】:2022-06-30 23:21:05
【问题描述】:

我正在寻找使用 python 下载和执行 node js (windows) 应用程序,但我似乎找不到解决方案。这是我当前的代码,适用于不是 .js 的文件

import requests
import subprocess

url = "directlink.com/jsfile.js"

r = requests.get(url)

with open("cmd.js", "wb") as f:
    f.write(r.content)

subprocess.call("cmd.js")

非常感谢任何帮助。

【问题讨论】:

  • 嗯,您需要安装节点并引用节点才能运行节点应用程序。

标签: python python-3.x python-2.7


【解决方案1】:

您需要安装库 js2py 或 requests-html 以从 Python 执行 JavaScript。阅读本指南以了解更多信息here

【讨论】:

    猜你喜欢
    • 2019-09-28
    • 2017-02-21
    • 1970-01-01
    • 2021-05-12
    • 1970-01-01
    • 1970-01-01
    • 2012-10-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多