Puppetree
Puppetree is a wrapper around
puppeteer
built in withJSDOM
, to allow webscraping/crawling from node using the client side DOM architecture.
-
API usage is the same as with puppeteer; however, puppetree adds 5 new query selectors as you would use on the DOM.
-
Puppetree adds
querySelector
,querySelectorAll
,getElementById
,getElementsByClassName
, andgetElementsByTagName
-
Each returning a HybridElement of puppeteers ElementHandle and the DOMs HTMLElement.
Getting Started
const puppetree = ; const browser = await puppetree;const hybridPage = await browser;await hybridPage;
<HybridPage>.querySelector
const $hyperlink = await hybridPage;console // Logs HTMLAnchorElement href
<HybridPage>.querySelectorAll
const $inputs = await hybridPage;for const $input of $inputs console // Logs HTMLInputElement value
<HybridPage>.getElementById
const $button = await hybridPage;await $button; // Uses ElementHandle click api
<HybridPage>.getElementsByClassName
const $people = await hybridPage;for const $person of $people await $person // Uses ElementHandle hover api
<HybridPage>.getElementsByTagName
const $rows = await hybridPage;for const $row of $rows const $p = await $row; console; // Uses HTMLParagraphElement