最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - Call js function in python to use document.getElementById - Stack Overflow

matteradmin7PV0评论

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 mand:

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 mand above?

Thanks in advance!

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 mand:

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 mand above?

Thanks in advance!

Share Improve this question edited Aug 23, 2016 at 14:03 Setily 8221 gold badge9 silver badges21 bronze badges asked Aug 23, 2016 at 13:59 soukisouki 1,3854 gold badges25 silver badges43 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 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")
Post a comment

comment list (0)

  1. No comments so far