Skip to content

html

Fully rendered HTML, captured after JavaScript runs. It resolves to a string:
const html = await microlink.html('https://example.com')
Unlike a plain fetch, the markup reflects the DOM after client-side rendering when prerender kicks in, so single-page applications return their real content.

Options

It takes the same scoping options as markdown:
  • selector <string> — returns the inner HTML of the first element matching the CSS selector.
  • selectorAll <string> | <string[]> — returns the inner HTML of every matching element, as an array.
  • type <string> — overrides how the extracted value is normalized, per the rules grammar.
Any shared option applies too.

Examples

Only the main content region:
const html = await microlink.html('https://example.com', {
  selector: 'main'
})
Grab every product card of a listing to parse on your side:
const cards = await microlink.html('https://example.com/shop', {
  selectorAll: '.product-card',
  waitForSelector: '.product-card'
})
Render a client-side application and inject a stylesheet before capturing the markup:
const html = await microlink.html('https://app.example.com', {
  prerender: true,
  styles: ['.banner { display: none }']
})
For the outer HTML of an element, or attributes instead of markup, write the rule yourself with extract and attr: 'outerHTML'.
See URL to HTML in the content conversion guide.