Skip to main content
Scrape functions extract data from HTML pages using CSS selectors, similar to Home Assistant’s scrape integration. They’re useful for websites without APIs.

Configuration

string
required
The URL of the web page to scrape
array
required
List of data points to extract from the page
string
required
Template that combines scraped sensor values into the function result

Sensor Configuration

Each sensor extracts a piece of data from the page:
string
required
Variable name to use in the main value_template
string
required
CSS selector to find the element
string
Template to process the selected element’s text
string
Extract an HTML attribute instead of text (e.g., href, src)

CSS Selectors

Advanced Features

Get HTML attributes instead of text:
Extract all matching elements:
Add custom headers (e.g., for authentication):

Use Cases

Version Tracking

Monitor software versions and releases

Price Monitoring

Track product prices and availability

News Aggregation

Extract headlines and articles

Status Pages

Monitor service status pages

Best Practices

1

Inspect the page

Use browser DevTools to find the right CSS selectors. Right-click an element and select “Inspect” to see its HTML structure.
2

Handle missing elements

Pages may change. Use safe filters and defaults:
3

Respect robots.txt

Check the website’s robots.txt to ensure scraping is allowed. Add appropriate delays for rate limiting.
4

Add User-Agent

Some sites block requests without a User-Agent header:

Debugging

Test CSS selectors in browser console:
Enable debug logging:

Examples

Get Home Assistant Version

Scrape the current version from home-assistant.io:
Scrape Example

Scrape Product Price

Extract Multiple Items

Comparison: Scrape vs REST

Next Steps

REST Functions

Use APIs when available

Composite Functions

Combine scraping with processing

Scrape Integration

HA scrape integration docs