Scrape - How to return style information which contains wind direction in degrees - Wunderground.com

Hi
The page I am scraping is this one:

I have no weather station and can’t therefore get an API key.

How can I return style information from a scrape sensor?
I can easily return the item “NNE” in the image below (marked with red), by using …

.wind-dial__container .text-bold

I’d like to be able to get the item shown by the pink arrow as I can derive wind direction from that.
I’m after the item 209deg in the element below. (This value is 180 degrees out from true wind direction).

<div _ngcontent-app-root-c262="" class="arrow-wrapper" style="transform: translateX(-50%) rotate(216deg);"><img _ngcontent-app-root-c262="" alt="img" src="//www.wunderground.com/static/images/pws/Wind-Marker.svg"></div>

Thanks All. :slight_smile:

I figured it out so here’s an update.

I moved my scrapes to YAML as the UI seemed limited.
By using attribute:style in the scrape sensor, the scrape returns in this format (as logged when the scrape debug is on):
transform:translateX(-50%) rotate(357deg);
I then manipulate that to return wind direction in degrees to the sensor.

scrape:
  - resource: https://www.wunderground.com/dashboard/pws/IHAUP8
    sensor:
      - name: Wind Degrees
        select: ".arrow-wrapper"
        index: 0
        value_template: >
            {% set raw = value.split("rotate(")[1].split("deg)")[0] |int %}
            {% if raw >= 180 %} {{raw - 180}}
            {% else %} {{raw + 180}}
            {% endif %}
        attribute: style

I also found the REST call to collect the data in json format.
I don’t know if the apiKey changes or needs anything else - it was still working the next day in a private browser window. I will investigate that in time (maybe).

To find it, while refreshing the page, used F12 + Network tab then filtered xhr requests.

https://api.weather.com/v3/aggcommon/v3alertsHeadlines;v3-wx-observations-current;v3-location-point?apiKey=-api-key-goes-here-&geocodes=-37.92%2C175.31&language=en-US&units=m&format=json

Cheers

awesome! thank you.

your scrape yaml looks way cleaner as my one… but still works… thx