Update scrape component to add optional headers (#6455)

Added headers optional parameter, plus example for BOM
This commit is contained in:
David Peterson 2018-10-03 20:48:25 +10:00 committed by Fabian Affolter
parent 10b8a12d4c
commit 5abe3bca8e

View File

@ -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 %}