- Created .dockerignore and .gitignore files to exclude unnecessary files from Docker builds. - Added Dockerfile for multi-stage build setup, including dependencies and production environment configuration. - Introduced docker-compose.yml for service orchestration, including FlareSolverr and the main application. - Implemented core functionality for downloading manga chapters, including utilities for handling file paths and chapter metadata. - Added ESLint configuration for code quality and consistency. - Included JSDoc configuration for documentation generation. - Established initial package.json and package-lock.json with necessary dependencies for the project.
20 lines
546 B
JavaScript
20 lines
546 B
JavaScript
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<object>} 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 };
|