【发布时间】:2020-06-17 14:43:30
【问题描述】:
所以我正在尝试获取网站的 HTML。由于大多数网站是使用脚本创建的,因此我使用“JSDOM”来“加载”网站。我的代码如下:
(async () => {
try {
const dom = new JSDOM(``, {
url: "https://www.google.com/",
referrer: "",
contentType: "text/html",
includeNodeLocations: true,
storageQuota: 10000000,
runScripts: "dangerously",
resources: "usable",
pretendToBeVisual: true
});
} catch(error) {
console.log(error)
}
})();
当我运行命令时出现错误
TypeError: Invalid URL:
at new URLImpl (C:\Users\jonco\Desktop\Nakada Manami\node_modules\whatwg-url\lib\URL-impl.js:21:13)
at Object.setup (C:\Users\jonco\Desktop\Nakada Manami\node_modules\whatwg-url\lib\URL.js:73:14)
at new URL (C:\Users\jonco\Desktop\Nakada Manami\node_modules\whatwg-url\lib\URL.js:105:22)
at transformOptions (C:\Users\jonco\Desktop\Nakada Manami\node_modules\jsdom\lib\api.js:239:43)
at new JSDOM (C:\Users\jonco\Desktop\Nakada Manami\node_modules\jsdom\lib\api.js:34:15)
at C:\Users\jonco\Desktop\Nakada Manami\index.js:109:16
at processTicksAndRejections (internal/process/task_queues.js:97:5)
我做错了什么?我花了过去 3 个小时试图弄清楚这一点。
【问题讨论】:
标签: discord.js jsdom