Bartosz Marcinkowski
Bartosz Marcinkowski

Reputation: 6881

Python3 executing Javascript

I need to execute a Javascript function from Python 3 (pass a few variables into it's environment and collect the result). I found pyv8 and python-spidermonkey, but neither supports Python 3.

Is there a library for that job?

Upvotes: 0

Views: 854

Answers (1)

Mikko Ohtamaa
Mikko Ohtamaa

Reputation: 83686

What you can always do:

  • Install Node.Js binaries on the server-side

  • Write a script as standalone .js file

  • Pass input as command-line arguments, pipes (stdin) or files

  • Execute the script using subprocess

  • Collect the result from a named pipe or file output

.js scripts can be executed in similar fashion as .sh and .py scripts.

Upvotes: 1

Related Questions