Let’s talk about the environment first: win7 64-bit, python3.8.10. When python uses execjs to execute js code containing document, an error will appear: execjs._exceptions.ProgramError: TypeError: ‘document’ is undefined The reason is that pure js code does not contain objects in the browser (such as document, window, etc.). In this case, a library called jsdom is […]
Tag: jsdom
Nodejs executes the script after loading the page using jsdom
The browser loads the page and then executes the script. This is because the browser environment exists, and the DOM JS can be loaded to execute the script. jsdom can be used as a substitute for the browser environment. After loading DOM JS with nodejs jsdom, it is also possible to execute scripts. Of course, […]