1

I've recently asked about a way to call a js function in python. People gave me advice such as using js2py, or pyv8, but the problem is that it does not allow me to use the following js command:

document.getElementById("example");

So my question is: Is there a way to call js from a python function and that allows you to use the js command above?

Thanks in advance!

Setily
  • 814
  • 1
  • 9
  • 21
souki
  • 1,305
  • 4
  • 23
  • 39

1 Answers1

3

If calling js function in python means: How can I select node with specific id?, then you can use BeautifulSoup for it:

from bs4 import BeautifulSoup

html_doc = "<html><head><title></title></head><body><div id='example'></body></html>"

soup = BeautifulSoup(html_doc, 'html.parser')
soup.find(id="example")
turkus
  • 4,637
  • 2
  • 24
  • 28