mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-23 09:17:06 +00:00
Update scrape component to add optional headers (#6455)
Added headers optional parameter, plus example for BOM
This commit is contained in:
parent
10b8a12d4c
commit
5abe3bca8e
@ -36,6 +36,7 @@ Configuration variables:
|
||||
- **authentication** (*Optional*): Type of the HTTP authentication. Either `basic` or `digest`.
|
||||
- **username** (*Optional*): The username for accessing the website.
|
||||
- **password** (*Optional*): The password for accessing the website.
|
||||
- **headers** (*Optional*): Headers to use for the web request
|
||||
|
||||
## {% linkable_title Examples %}
|
||||
|
||||
@ -130,3 +131,23 @@ sensor:
|
||||
unit_of_measurement: "öre/kWh"
|
||||
```
|
||||
{% endraw %}
|
||||
|
||||
### {% linkable_title BOM Weather %}
|
||||
|
||||
The Australian Bureau of Meterology website returns an error if the User Agent header is not sent.
|
||||
|
||||
{% raw %}
|
||||
```yaml
|
||||
# Example configuration.yaml entry
|
||||
sensor:
|
||||
- platform: scrape
|
||||
resource: http://www.bom.gov.au/vic/forecasts/melbourne.shtml
|
||||
name: Melbourne Forecast Summary
|
||||
select: ".main .forecast p"
|
||||
value_template: '{{ value | truncate(255) }}'
|
||||
# Request every hour
|
||||
scan_interval: 3600
|
||||
headers:
|
||||
User-Agent: Mozilla/5.0
|
||||
```
|
||||
{% endraw %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user