Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

call an external javascript function from python

I have a javascript function that I can call with input and that returns a result. I can integrate this javascript function into an html-document (of course).

Now I would like to call exactly this javascript function from python. I have a python programm and want to call the javascript function with input parameters passed to the JS function by the calling python function. And the JS function shall return some result to python.

This JS function has quite complex functionality and is used in a web project also. I would like to use same functionality in Python.

Does anyone know how to solve this? Python is quite huge so I think I only did not find the required python module up until know. I spent 2 days in searching a possibility.

Thanks!

like image 719
Walter Avatar asked Sep 14 '25 21:09

Walter


1 Answers

pyv8 will let you use the V8 JS engine from Python.

If the JavaScript function depends on things that are not core JavaScript (such as DOM) then you will need to find implementations of those.

like image 184
Quentin Avatar answered Sep 17 '25 13:09

Quentin