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_templatestring
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
Basic Selectors
Basic Selectors
Combinators
Combinators
Attribute Selectors
Attribute Selectors
Pseudo-classes
Pseudo-classes
Advanced Features
Extract Attributes
Extract Attributes
Get HTML attributes instead of text:
Multiple Elements
Multiple Elements
Extract all matching elements:
Headers
Headers
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:Examples
Get Home Assistant Version
Scrape the current version from home-assistant.io: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