Created
November 21, 2021 07:50
-
-
Save huksley/81213fc562f2ae1fd787fcb8006185d9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const jsdom = require("jsdom"); | |
const { JSDOM } = jsdom; | |
const userAgent = | |
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:89.0) Gecko/20100101 Firefox/89.0"; | |
const cookieJar = new jsdom.CookieJar(); | |
const resources = new jsdom.ResourceLoader({ | |
userAgent | |
}); | |
const defs = { | |
referrer: "https://google.com", | |
includeNodeLocations: true, | |
storageQuota: 10000000, | |
pretendToBeVisual: true, | |
cookieJar, | |
resources | |
}; | |
JSDOM.fromURL("https://google.com", defs).then(dom => { | |
const document = dom.window.document; | |
const nodes = Array.from(document.querySelectorAll("div")); | |
console.info(nodes); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment