Scrapping With JavaScript

DOM Parser creates a document from plaintext html.

Grabbing the entire HTML document with JS - Stackoverflow

  • '<!DOCTYPE HTML>' + '\n' + document.documentElement.outerHTML
  • new XMLSerializer().serializeToString(document)

new URL("https://example.org/")

Querries

document.querySelectorAll("h1, h2, h3, h4, h5, h6");

Abstract Objects

Getting position on page Stackoverflow MDN Docs getBoundingClientRect

// relative to viewport
var rect = element.getBoundingClientRect(); // read only
console.log(rect.top, rect.right, rect.bottom, rect.left);
// adjust for scroll
rect.left+window.scrollX;
rect.top+window.scrollY
// for reference
window.screen.width;
window.screen.height