node.js - 使用jsdom运行脚本后如何抓取整个html
问题描述
如何在使用jsdom运行脚本后抓取整个 html 这是我要抓取的链接。 https://cma.org.sa/Market/imf/Pages/default.aspx
const fs = require('fs');
const jsdom = require('jsdom');
const { JSDOM } = jsdom;
const pdfUrl = 'https://cma.org.sa/Market/imf/Pages/default.aspx';
async function loadListView(){
const dom = await JSDOM.fromURL(pdfUrl, {
includeNodeLocations: true,
pretendToBeVisual: true,
runScripts: 'dangerously',
resources: "usable",
});
dom.window.document.querySelectorAll('a').forEach(link => {
console.log(link.href);
});
return dom;
}
loadListView()
我的代码只是在运行脚本之前获取 html。但我需要在运行所有脚本后 __scrape__ html 页面。谢谢。
解决方案
推荐阅读
- database - 使用 UPDATE 交换 SQLite3 中列的值
- javascript - 是否可以在 dialogflow 内联编辑器中使用外部库?
- php - 尝试创建 CMS 但无法登录
- r - 单击具有相同 css RSelenium 的所有元素
- amazon-web-services - 在处理整个有效负载之前,S3Stream 正在关闭
- python - Pandas 中按日期范围进行有效过滤
- asp-classic - ASP 中的会话不存储值
- matlab - 在矩阵列中的每个组中查找最接近的值
- c++ - 声明变量时逗号分隔如何起作用
- angular - 具有多个过滤器的 PrimeNG 全局过滤器