How do I call a Javascript function from Python?

Kiran picture Kiran · Nov 27, 2011 · Viewed 88.3k times · Source

I am working on a web-scraping project. One of the websites I am working with has the data coming from Javascript.

There was a suggestion on one of my earlier questions that I can directly call the Javascript from Python, but I'm not sure how to accomplish this.

For example: If a JavaScript function is defined as: add_2(var,var2)

How would I call that JavaScript function from Python?

Answer

Has QUIT--Anony-Mousse picture Has QUIT--Anony-Mousse · Nov 27, 2011

Find a JavaScript interpreter that has Python bindings. (Try Rhino? V8? SeaMonkey?). When you have found one, it should come with examples of how to use it from python.

Python itself, however, does not include a JavaScript interpreter.