It is currently April 24th, 2024, 7:52 am

Two WebParser measures show same value even they are from different page!

Get help with creating, editing & fixing problems with skins
Themer992
Posts: 1
Joined: May 21st, 2023, 9:16 pm

Two WebParser measures show same value even they are from different page!

Post by Themer992 »

Since every single weather skin I found on internet is broken because weather.com is not working anymore...
so I started to make my own weather skin.

I'm using translator with little text modification with little fluency of English...
So please understand.

Image

Well my skin is simple.
It shows temperature, today's sky status (Clear, Cloudy, Foggy), and finally air condition (Fine dust, and Ultra fine dust).

Here, the circle on the left and right is a circle representing fine dust and ultrafine dust, respectively.
The left circle is from https://www.airkorea.or.kr/web/vicinityStation?item_code=10007&station_code=111274
The right circle (ultra-fine dust) is taken from https://www.airkorea.or.kr/web/vicinityStation?item_code=10008&station_code=111274

I got it from a completely different webpage and it's really weird that I get the same value as shown on the picture.

I re-checked it with RegExp because I was wondering if this is because of a wrong regular expression
https://docs.rainmeter.net/tips/webparser-debugging-regexp/
using RainRegExp on the Rainmeter website

Image

If I scratch it from the fine dust website, 87 comes up

Image

If I put it on the ultrafine dust site, 21 appears.
So I found regular expressions were completely OK.

I even checked that they came up differently
Strangely, if I just put it in the rainmeter, I still get the same value...

I really don't know why this problem is happening, so I'm asking

This is the code.

Code: Select all

;-------- URL --------

;Here is a RegExp that scrapes only the fine dust levels from each Air Korea site.
;https://docs.rainmeter.net/tips/webparser-debugging-regexp/
;I debugged it using the RainRegExp programme in the link above, and there was no problem.
;But there's something strange, when I apply it to the skin only, it only shows the same numbers, even though they are obviously different.

[MeasureAIR]
Measure=Plugin
Plugin=Plugins\Webparser.dll
URL=https://www.airkorea.or.kr/web/vicinityStation?item_code=10007&station_code=111274
RegExp="(?siU)30px;">(.*?)<p class="fs"
Updaterate=3600
StringIndex=1
;Fine dust 

[MeasureAIR_PM25]
Measure=Plugin
Plugin=Plugins\Webparser.dll
URL=https://www.airkorea.or.kr/web/vicinityStation?item_code=10008&station_code=111274
RegExp="(?siU)30px;">(.*?)<p class="fs"
Updaterate=3600
StringIndex=1
;Ultra fine dust

;-------- Measure AIR --------
[MeasureValue]
Measure=Plugin
Plugin=Plugins\Webparser.dll
URL=[MeasureAIR]
StringIndex=1
DynamicVariables=1
;Fine dust

[MeasureStatus]
Measure=Calc
Formula=MeasureValue
IfCondition=(MeasureValue >= 0) && (MeasureValue <= 30)
IfTrueAction=[!SetVariable AirColor "46,193,66"]
IfCondition2=(MeasureValue >= 31) && (MeasureValue <= 80)
IfTrueAction2=[!SetVariable AirColor "14,114,202"]
IfCondition3=(MeasureValue >= 81) && (MeasureValue <= 150)
IfTrueAction3=[!SetVariable AirColor "210,99,0"]
IfCondition4=(MeasureValue > 151)
IfTrueAction4=[!SetVariable AirColor "255,0,0"]
DynamicVariables=1
;"The air condition (fine dust value) will be shown inside the circle"
;and this is the part that decides its circle's color.
;If air condition gets bad, the color of it will turn to red.

[MeasureValue2]
Measure=Plugin
Plugin=Plugins\Webparser.dll
URL=[MeasureAIR_PM25]
StringIndex=1
DynamicVariables=1
;[MeasureValue2] and [MeasureStatus2] is about "Ultra fine dust value."
;Same explanation with above part.

[MeasureStatus2]
Measure=Calc
Formula=MeasureValue2
IfCondition=(MeasureValue2 >= 0) && (MeasureValue2 <= 15)
IfTrueAction=[!SetVariable AirColorPM25 "46,193,66"]
IfCondition2=(MeasureValue2 >= 16) && (MeasureValue2 <= 35)
IfTrueAction2=[!SetVariable AirColorPM25 "14,114,202"]
IfCondition3=(MeasureValue2 >= 36) && (MeasureValue2 <= 75)
IfTrueAction3=[!SetVariable AirColorPM25 "210,99,0"]
IfCondition4=(MeasureValue2 > 76)
IfTrueAction4=[!SetVariable AirColorPM25 "255,0,0"]
DynamicVariables=1
I have put both the original code that I was working on and the code that left only the air quality measure function for easy viewing with comment in the compressed file.

<Full Code>
Weather Widget.zip
I would appreciate it if you answer to my question...
You do not have the required permissions to view the files attached to this post.
Last edited by eclectic-tech on May 21st, 2023, 11:05 pm, edited 1 time in total.
Reason: Please use the code tag </> when posting long codes.
User avatar
SilverAzide
Rainmeter Sage
Posts: 2604
Joined: March 23rd, 2015, 5:26 pm

Re: Two WebParser measures show same value even they are from different page!

Post by SilverAzide »

Themer992 wrote: May 21st, 2023, 10:47 pm
Because your two URLs differ only in some parameters, the problem is data caching. After the skin loads the first time, the subsequent calls to the site are fetching data from the same cache. Add the following option to your two parent WebParser measures:

Code: Select all

Flags=Resync | NoCookies

Some additional comments for you:
First, WebParser is now a built-in measure, not a plugin. So your measures should be changed from this:

Code: Select all

Measure=Plugin
Plugin=Plugins\Webparser.dll
to simply this:

Code: Select all

Measure=WebParser
Secondly, perhaps it is just your trimmed down example code, but your [MeasureValue] and [MeasureValue2] measures don't do anything. Since your parent WebParser measures use a RegExp that strips out all the data except for what you want, the child measures are simply echoing the same data, and therefore are not needed. But perhaps your real skin is doing other things, I did not download it.
Gadgets Wiki GitHub More Gadgets...
User avatar
SilverAzide
Rainmeter Sage
Posts: 2604
Joined: March 23rd, 2015, 5:26 pm

Re: Two WebParser measures show same value even they are from different page!

Post by SilverAzide »

Themer992 wrote: May 21st, 2023, 10:47 pm Since every single weather skin I found on internet is broken because weather.com is not working anymore...
so I started to make my own weather skin.
Weather.com is working, it's the skins that are not working because they are very out of date. It's usually not too difficult to fix the skins yourself; there are some tutorials that can help:

[Troubleshooting Guide] Weather or web skins are not working
Step-by-Step Basic Weather Skin Tutorial

Finally, here is a curated list of weather skins known to work:
Weather Skins
Gadgets Wiki GitHub More Gadgets...