Create a browser environment to download nodejs

The command is as follows

Start cmd window to execute instructions

05a9572f05854078a8bae7d7e74fc5ca.png

 The wait is over

Create js file

Write the following code

74dabe5fc5f84805af7bd1eb35fbfb36.png

 const jsdom=require("jsdom")const {JSDOM}=jsdomconst resourceLoader=new jsdom.ResourceLoader({ userAgent: "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36 Core/1.94.196.400 QQBrowser/11.7.5286.400"});const html="<!DOCTYPE html><p>Hello world</p>";const dom=new JSDOM(html,{ url:"https://www.endata.com.cn/BoxOffice/BO/Year/index.html", referrer:"https://www.endata.com.cn/BoxOffice/BO/Year/index.html", contentType:"text/html", resource:resourceLoader,});window=global;const params={ location:{ hash: "", host: "www.endata.com.cn/", hostname: "www.endata.com.cn/", href: "https://www.endata.com.cn/BoxOffice/BO/Year/index.html", origin: "https://www.endata.com.cn/BoxOffice/BO/Year/index.html", pathname: "/", port: "", protocol: "http:", search: "" }, navigator:{ userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36 Edg/92.0.902.67", }}//拼接对象Object.assign(global,params)document=dom.window.documentwindow=dom.window

 You can write js function below

e30e904a84c4468fb10bf2fa19ac8c23.png

 Use python to call js as follows

Import module execjs

49738455488249f8a3b58999c173d5ee.png

 

If not, you can install it with pip

Configure the package path of the module

16ea785d60b648ada328fe956beba105.png

 The picture has been blocked because it contains sensitive information.

Take a look at the code and copy it to run the js code

afaa128cca26498c9c67d27a5b717b8e.png

 

Guess you like

Origin blog.csdn.net/qq1278169704/article/details/130397911