La commande est la suivante
Démarrez la fenêtre cmd pour exécuter la commande
L'attente est terminée
Créer un fichier js
Écrivez le code suivant
const jsdom=require("jsdom")const {JSDOM}=jsdomconst resourceLoader=new jsdom.ResourceLoader({ userAgent : "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, comme Gecko) Chrome/94.0.4606.71 Safari/537.36 Core/1.94.196.400 QQBrowser/11.7.5286.400"});const html="<!DOCTYPE html><p>Bonjour tout le monde</p>";const dom=new JSDOM(html,{ url:"https ://www.endata.com.cn/BoxOffice/BO/Year/index.html", référent :"https://www.endata.com.cn/BoxOffice/BO/Year/index.html", contentType : "text/html", ressource:resourceLoader,});window=global;const params={ location:{ hash: "", hôte: "www.endata.com.cn/", nom d'hôte: "www.endata.com .cn/", href : "https://www.endata.com.cn/BoxOffice/BO/Year/index.html", origine : "https://www.endata.com.cn/BoxOffice/BO/Year/index.html", chemin d'accès : "/", port : "", protocole : "http:", recherche : "" }, navigateur :{ userAgent : "Mozilla/5.0 (Windows NT 10.0 ; Win64; x64) AppleWebKit/537.36 (KHTML, comme Gecko) Chrome/92.0.4515.131 Safari/537.36 Edg/92.0.902.67", }}//拼接对象Object.assign(global,params)document=dom.window.documentwindow =dom.fenêtre
Vous pouvez écrire la fonction js ci-dessous
Utilisez Python pour appeler js comme suit
Importer les execjs du module
Sinon, vous pouvez l'installer avec pip
Configurer le chemin du package du module
L'image a été bloquée car elle contient des informations sensibles.
Jetez un œil au code et copiez-le pour exécuter le code js