It is currently March 28th, 2024, 11:38 pm

⭐ Weather.com - Parsing the V3 JSON

Our most popular Tips and Tricks from the Rainmeter Team and others
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: ⭐ weather.com - Parsing the JSON

Post by balala »

GeekySavage wrote: April 22nd, 2020, 3:28 am Hello I have a skin im trying to figure out to have the weather shown up....Im having a hard time. This is not mine.

Code: Select all

[Raimeter]
Author=Darknesfreak.deviantart.com
Update=1000


-------- # # # # # Begin Measure & Variables # # # # # -------

[Variables]
Location=CAXX0042
Type=M

-----------------------------------------------------------------------
######## change the location to your correspondent area code  #########
######## use this web site ########## http://www.weather.com/ #########
-----------------------------------------------------------------------




[Current]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=3000
Url=https://weather.com/en-CA/weather/today/l/6c8919935ebfd53c96bfd77c0c8aa808924a384c26cedebf43cba5da1f063004
RegExp="(?siU).*<locale>(.*)</locale>.*<ut>(.*)</ut>.*<ud>(.*)</ud>.*<us>(.*)</us>.*<up>(.*)</up>.*<ur>(.*)</ur>.*<loc id="(.*)">.*<dnam>(.*)</dnam>.*<tm>(.*)</tm>.*<lat>(.*)</lat>.*<lon>(.*)</lon>.*<sunr>(.*)</sunr>.*<suns>(.*)</suns>.*<zone>(.*)</zone>.*<cc>.*<lsup>(.*)</lsup>.*<obst>(.*)</obst>.*<tmp>(.*)</tmp>.*<flik>(.*)</flik>.*<t>(.*)</t>.*<icon>(.*)</icon>.*<bar>.*<r>(.*)</r>.*<d>(.*)</d>.*<wind>.*<s>(.*)</s>.*<gust>(.*)</gust>.*<d>(.*)</d>.*<t>(.*)</t>.*<hmid>(.*)</hmid>.*<vis>(.*)</vis>.*<uv>.*<i>(.*)</i>.*<t>(.*)</t>.*<dewp>(.*)</dewp>.*<moon>.*<icon>(.*)</icon>.*<t>(.*)</t>.*"

--------------------------------------------------------
--------------------------------------------------------


[MeasureTemp]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[Current]
StringIndex=17

--------------------------------------------------------
--------------------------------------------------------


[MeasureStatus]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[Current]
StringIndex=19
Substitute=" And ":" and ","Lgt.":"Light ","Snow/":"Snow & "


--------------------------------------------------------
--------------------------------------------------------



-------- # # # # # Begin Meters # # # # # --------


--------------------------------------------------------
--------------------------------------------------------



[BG]
Meter=IMAGE
ImageName=#SKINSPATH#\Triangulation\Resources\WeatherTri.png
X=0
Y=0


--------------------------------------------------------
--------------------------------------------------------


Can someone help with this? Thanks
Although you've replaced the URL option with the new one, the RegExp is still the old, you didn't rewrite it as well. That's why it is not working. So you have to rewrite it and you have to change the StringIndex values of the child WebParser measures as well.
So, replace the regExp option of the [Current] measure with the following one:

Code: Select all

[Current]
...
RegExp=(?siU)(?(?=.*</div></span><p class="today_nowcard-).*timestamp"><span>(.*)<!----> </span><span>(.*)</span>).*(?(?=.*<div class="today_nowcard-section today_nowcard-condition"><div class="condition-icon wx-weather-icon vector).*"><icon class="icon icon-svg icon-svg-.* .* icon-(.*)" className="icon icon-svg icon-svg-.* .* icon-.*">.*</icon></div>)(?(?=.*<div class="today_nowcard-temp").*><span class="">(.*)<sup>(.*)</sup></span>).*(?(?=.*<div class="today_nowcard-phrase).*">(.*)</div>)(?(?=.*<div class="today_nowcard-feels).*"><span class="btn-text">(.*)<!----> </span><span class="deg-feels" className="deg-feels">(.*)<sup>(.*)</sup></span>).*(?(?=.*<div class="today_nowcard-hilo").*><span class="btn-text">.*<!----> </span><span class="deg-hilo-nowcard"><span class="">(.*)<sup>(.*)</sup></span>).*(?(?=.*<span class="btn-text">.*<!---->).* </span><span class="deg-hilo-nowcard"><span class="">(.*)<sup>(.*)</sup></span>).*(?(?=.*<div class="today_nowcard-sidecar component panel"><table><caption>(.*)</caption><tbody>).*<tr><th>(.*)</th><td><span class="">(.*)</span></td></tr><tr><th>(.*)</th><td><span class=""><span>(.*)<span class="Percentage__percentSymbol__2Q_AR">(.*)</span></span></span></td></tr><tr><th>.*</th><td><span class="">.*<sup>.*</sup></span></td></tr><tr><th>(.*)</th><td><span class="">(.*)<!---->.*</span></td></tr><tr><th>(.*)</th><td><span class="">(.*)</span></td>)
Rewrite the StringIndex options of the chile measures as it follows:

Code: Select all

[MeasureTemp]
...
StringIndex=4

[MeasureStatus]
...
StringIndex=6
That's all. Does it work?
LuciiDevotee
Posts: 1
Joined: April 25th, 2020, 8:57 pm

Re: ⭐ weather.com - Parsing the JSON

Post by LuciiDevotee »

Hi there, I'm new to rainmeter, and while trying to figure out how to make my weather skin work I found this forum post.. Could anyone help me possibly, I'm at a lost and have no idea how to make my skin "Beeping Weather For Rainmeter" work properly, even after reading this.. I included the weather file for it below (although I'm unsure if that will even help with this..) I'm sorry once again, completely new here fell down the youtube rabbit hole and found rainmeter.. Any help is much appreciated!
Weather-Dark.ini
Weather.ini
You do not have the required permissions to view the files attached to this post.
GeekySavage
Posts: 2
Joined: April 22nd, 2020, 3:25 am

Re: ⭐ weather.com - Parsing the JSON

Post by GeekySavage »

balala wrote: April 22nd, 2020, 9:56 am Although you've replaced the URL option with the new one, the RegExp is still the old, you didn't rewrite it as well. That's why it is not working. So you have to rewrite it and you have to change the StringIndex values of the child WebParser measures as well.
So, replace the regExp option of the [Current] measure with the following one:

Code: Select all

[Current]
...
RegExp=(?siU)(?(?=.*</div></span><p class="today_nowcard-).*timestamp"><span>(.*)<!----> </span><span>(.*)</span>).*(?(?=.*<div class="today_nowcard-section today_nowcard-condition"><div class="condition-icon wx-weather-icon vector).*"><icon class="icon icon-svg icon-svg-.* .* icon-(.*)" className="icon icon-svg icon-svg-.* .* icon-.*">.*</icon></div>)(?(?=.*<div class="today_nowcard-temp").*><span class="">(.*)<sup>(.*)</sup></span>).*(?(?=.*<div class="today_nowcard-phrase).*">(.*)</div>)(?(?=.*<div class="today_nowcard-feels).*"><span class="btn-text">(.*)<!----> </span><span class="deg-feels" className="deg-feels">(.*)<sup>(.*)</sup></span>).*(?(?=.*<div class="today_nowcard-hilo").*><span class="btn-text">.*<!----> </span><span class="deg-hilo-nowcard"><span class="">(.*)<sup>(.*)</sup></span>).*(?(?=.*<span class="btn-text">.*<!---->).* </span><span class="deg-hilo-nowcard"><span class="">(.*)<sup>(.*)</sup></span>).*(?(?=.*<div class="today_nowcard-sidecar component panel"><table><caption>(.*)</caption><tbody>).*<tr><th>(.*)</th><td><span class="">(.*)</span></td></tr><tr><th>(.*)</th><td><span class=""><span>(.*)<span class="Percentage__percentSymbol__2Q_AR">(.*)</span></span></span></td></tr><tr><th>.*</th><td><span class="">.*<sup>.*</sup></span></td></tr><tr><th>(.*)</th><td><span class="">(.*)<!---->.*</span></td></tr><tr><th>(.*)</th><td><span class="">(.*)</span></td>)
Rewrite the StringIndex options of the chile measures as it follows:

Code: Select all

[MeasureTemp]
...
StringIndex=4

[MeasureStatus]
...
StringIndex=6
That's all. Does it work?
Im still having a difficulty following
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: ⭐ weather.com - Parsing the JSON

Post by balala »

GeekySavage wrote: April 25th, 2020, 11:07 pm Im still having a difficulty following
Why, what you can't follow? It's not complicated:
  • Replace the RegExp option of the [Current] measure as I wrote above.
  • Replace the value of the StringIndex option within the [MeasureTemp] measure with StringIndex=4 and the StringIndex within [MeasureStatus] with StringIndex=6.
  • There are (is) (I hope) some not posted meter(s), which should show the value(s) returned by the above measure(s). Are they (is it)? If they are (it is), just refresh the skin.
Do you get it working?
User avatar
Yincognito
Rainmeter Sage
Posts: 7029
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: ⭐ weather.com - Parsing the JSON

Post by Yincognito »

dvo wrote: May 1st, 2020, 6:54 pm weather.com missing the celcius sign... :Whistle
First, it's Celsius, not celcius. Secondly, there isn't a "sign" for Celsius, it's simply C (just like F for Fahrenheit). Only the degree (be it Celsius, Fahrenheit or Kelvin) has a "sign", the degree symbol (°).

And sure, the JSON part doesn't bother to put a degree symbol or a Celsius indicator next to the temperature values. The former isn't that hard to add in Rainmeter, while the latter is found anyway in the "unitOfMeasurement" section of the JSON:

Code: Select all

"unitOfMeasurement":{"units":"m","temp":"C","speed":"km\u002Fh","distance":"km","accumulation":"cm","precip":"mm","pressure":"mb"}
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: ⭐ weather.com - Parsing the JSON

Post by balala »

Yincognito wrote: May 1st, 2020, 7:07 pm Only the degree (be it Celsius, Fahrenheit or Kelvin) has a "sign", the degree symbol (°).
Not to nitpick, but the Kelvin scale doesn't use degrees. Celsius and Fahrenheit are expressed in degrees (Celsius or Fahrenheit), but Kelvin is an absolute temperature scale, a temperature expressed in Kelvin is not degree Kelvin, but just Kelvin.
Not too widely used though...
User avatar
Yincognito
Rainmeter Sage
Posts: 7029
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: ⭐ weather.com - Parsing the JSON

Post by Yincognito »

balala wrote: May 1st, 2020, 7:25 pm Not to nitpick, but the Kelvin scale doesn't use degrees. Celsius and Fahrenheit are expressed in degrees (Celsius or Fahrenheit), but Kelvin is an absolute temperature scale, a temperature expressed in Kelvin is not degree Kelvin, but just Kelvin.
Not too widely used though...
My bad, you're right. :oops:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Yincognito
Rainmeter Sage
Posts: 7029
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: ⭐ weather.com - Parsing the JSON

Post by Yincognito »

dvo wrote: May 1st, 2020, 7:27 pm pfffff :rolmfao: it's missing where it was showing it .... so weather.com doesn't show it any more... that's what i was saying.... :-(
You mean on the actual site? Just tested, yes, you're right. Must be some temporary slip-up from their part - hopefully it won't last, cause it's really awkward, indeed - on that we fully agree. :thumbup:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
iron2000
Posts: 15
Joined: June 6th, 2011, 3:47 am

Re: ⭐ weather.com - Parsing the JSON

Post by iron2000 »

Not sure is it temporary or they changed something.
The embedded JSON seems to be gone and the RegEx is picking up nothing.

At least on my skin.
Was working fine for a few days (switched to the JSON code on the 19th), just broke a like an hour ago.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ weather.com - Parsing the JSON

Post by jsmorley »

iron2000 wrote: May 21st, 2020, 6:38 pm Not sure is it temporary or they changed something.
The embedded JSON seems to be gone and the RegEx is picking up nothing.

At least on my skin.
Was working fine for a few days (switched to the JSON code on the 19th), just broke a like an hour ago.
Try restarting Rainmeter. Nothing has changed.