const axios = require("axios"); const { parse } = require("node-html-parser"); /** * Fetches HTML from a URL and returns the parsed document root. * @async * @param {string} url - Absolute URL to fetch. * @returns {Promise} Parsed HTML root (node-html-parser tree). */ async function fetchAndParseHtml(url) { const { data } = await axios.get(url, { responseType: "text", validateStatus: (status) => status >= 200 && status < 300, timeout: 15_000, }); return parse(data); } module.exports = { fetchAndParseHtml };