ApiSkills

Web Scraping · 9 min

Scraping in n8n & Power Query

Turn selectors into data with n8n HTML Extract node and Power Query Html.Table — including how to grab attributes, not just text.

Once you can write selectors, two tools turn them into rows: the n8n HTML node and Power Query Html.Table. Both take a CSS selector and return what it matches.

n8n — the HTML (Extract) node

  • Fetch the page with an HTTP Request node, then add an HTML node set to "Extract HTML Content".
  • Each extraction is a CSS Selector + a Return Value. Text = the visible text; Attribute (then a name like href or src) = an attribute value — use Attribute for links and image paths, since an image tag has no visible text.
  • Return Array ON returns one item per match (e.g. every product); OFF returns only the FIRST match and silently drops the rest.
  • Skip Selectors strips a child (e.g. .badge) out of a parent so its wording does not leak into the parent Text.
# The request behind an extraction:
GET /samples/store
# HTML node → selector ".product .title", Return Value = Text, Return Array = on
# For the image path: selector ".product .thumb", Return Value = Attribute, name = src

Power Query — Html.Table

Html.Table(html, columns) takes the page HTML plus a list of column definitions. Each column is {name, selector} for visible text, or {name, selector, each [Attributes][attr]} to pull an attribute instead.

let
    Source = Text.FromBinary(Web.Contents("https://YOUR-PORTAL/samples/store")),
    Products = Html.Table(Source, {
        {"title", ".product .title"},
        {"price", ".product .price"},
        {"image", ".product .thumb", each [Attributes][src]}
    })
in
    Products

Tip · Ready-made versions of both are in the Cookbook under "Web Scraping" — an n8n workflow and a Power Query query, both pointed at /samples/store. Practice the selectors in the Scraping Lab (/scraping) first.