Documentation for Site class:
The Site class provides static methods for retrieving and manipulating the content of a web page. It uses the node-fetch package to fetch the HTML content of a web page and the JSDOM package to create a virtual DOM object that can be manipulated with jQuery.
Methods:
getWindow(domainURL: string): Promise<Window>
: This method takes a domain URL as input and returns a Promise that resolves to a Window object. The Window object is created from the HTML content of the web page using the JSDOM package. The Window object represents a virtual browser window that can be used to manipulate the content of the web page.getDocument(domainURL: string): Promise<Document>
: This method takes a domain URL as input and returns a Promise that resolves to a Document object. The Document object is created from the HTML content of the web page using the JSDOM package. The Document object represents a virtual document object that can be used to manipulate the content of the web page.get$(domainURL: string): Promise<JQueryStatic>
: This method takes a domain URL as input and returns a Promise that resolves to a jQuery object. The jQuery object is created from the Window object using the jQuery package. The jQuery object can be used to manipulate the content of the web page using jQuery syntax.
Example usage:
import { Site } from "site-utils"
// get the document object for a web page const document = await Site.getDocument("https://example.com")
// get the jQuery object for a web page const $ = await Site.get$("https://example.com")
// use jQuery to manipulate the content of the web page $("h1").text("Hello World!")
To use this package in your own project, you can install it from NPM using the following command:
npm install site-utils
You can then import the Site class into your project and use its methods to manipulate the content of web pages.