Re: ⭐ weather.com - Parsing the JSON
Posted: May 22nd, 2020, 10:50 am
Ok, so after examining and formatting the WebParserDump.txt that I was able to download using the Debug=2 option and wondering why the data seemed to be available but the regex failed, it appears that they indeed changed their format ... but only for accessing stuff from "outside" a browser. In other words, while in the browser the page source would appear the same as before, what is "served" to the WebParser measure is significantly different.
Long story short, this should work for you - let me know if it doesn't (replace the latitude and longitude values with your own):
Basically, what you should do to build an "updated" regex is to set Debug=2 in your WebParser (you can uncomment it in the skin sample above, if you like) just one time in order to get how the source served to WebParser looks like in WebParserDump.txt, optionally format it for clarity in a clone file and then set your regex(es) accordingly.
Or ... you could wait for jsmorley to do that for you, of course.
Long story short, this should work for you - let me know if it doesn't (replace the latitude and longitude values with your own):
Code: Select all
[Variables]
Latitude=0
Longitude=0
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
BackgroundMode=2
SolidColor=47,47,47,255
---Measures---
[MeasureWebParser]
Measure=WebParser
Url=https://weather.com/en-GB/weather/today/l/#Latitude#,#Longitude#
;Debug=2
RegExp=^(?siU).*"getSunV3CurrentObservationsUrlConfig":\{.*"temperature":(.*),.*$
UpdateRate=600
[MeasureTemperature]
Measure=WebParser
Url=[MeasureWebParser]
StringIndex=1
---Meters---
[MeterTemperature]
Meter=STRING
X=0
Y=0
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
MeasureName=MeasureTemperature
Text="Temperature = %1 °C"
Or ... you could wait for jsmorley to do that for you, of course.