It is currently September 16th, 2024, 7:25 pm

Can't pass measure value to web parser

Get help with creating, editing & fixing problems with skins
Kotofanchik
Posts: 158
Joined: March 15th, 2024, 7:30 pm

Re: Can't pass measure value to web parser

Post by Kotofanchik »

balala wrote: June 24th, 2024, 6:29 pm
:thumbup:
The [mfactvalidHourcalc] measure looks not to be necessary. It's only reason is the use of the IfCondition (and obviously the appropriate IfTrueAction). But these options can be added directly to the [mfactvalidHour] WebParser measure, no need for another measure, just to add the IfCondition to that measure.

Not sure where any option of the parent WebParser measure ([mTotal] in this case) has been altered (at least not from the posted piece of code). Am I missing something?
Yes, there is something there that is not necessary for work (for example [mfactvalidHourcalc]), but I used it when trying to figure out the problem. Now I’ll start removing the excess.
User avatar
Yincognito
Rainmeter Sage
Posts: 8153
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Can't pass measure value to web parser

Post by Yincognito »

balala wrote: June 24th, 2024, 6:29 pmNot sure where any option of the parent WebParser measure ([mTotal] in this case) has been altered (at least not from the posted piece of code). Am I missing something?
Not entirely, the [mTotal] parent WebParser indeed wasn't altered, but one of its children (i.e. [mStartHour]) is or will be, due to its RegExp="(?siU)forecast valid=\".*T[mfactvalidHourcalc]:\d+:\d+\" tod(.*)$" which, as per the OP's request, "should" be using the desired non-zero hour from the fact valid=.*T(\d+):\d+:\d+\ part in the response, during the 2nd request. In this case, the manual says:
If you dynamically change an option on a "child" WebParser measure that depends on a "parent" measure, (like StringIndex for instance) you MUST use !CommandMeasure with "Update", targeting the "parent" WebParser measure. The values of child WebParser measures are a function of the parent measure, and are only updated when the parent is.
I know, it's highly redundant and personally I'd never poll a site twice in this case, since I can get all the forecast and filter it later in a different way (like described above), but well, that was the OP's idea. I was a bit unclear in my earlier reply when saying "WebParser works" - what I meant was "WebParser measures - both parent and children - work", sorry for the potential confusion.

In short, the OP wants to parse a WebParser child based on another WebParser child (if the latter is non zero). Kind of convoluted, if you ask me, but that's the idea.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
Kotofanchik
Posts: 158
Joined: March 15th, 2024, 7:30 pm

Re: Can't pass measure value to web parser

Post by Kotofanchik »

I can get all the forecast and filter it later
Taking into account that. that now the site really has to be polled twice, I need to think about this method, but so far it is not clear to me. Or save the site to a temporary file, like this possibility is described, and then send the skin to this temporary file? This can help? The site really doesn't like multiple requests.
User avatar
Yincognito
Rainmeter Sage
Posts: 8153
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Can't pass measure value to web parser

Post by Yincognito »

Kotofanchik wrote: June 24th, 2024, 6:57 pm Taking into account that. that now the site really has to be polled twice, I need to think about this method, but so far it is not clear to me. Or save the site to a temporary file, like this possibility is described, and then send the skin to this temporary file? This can help? The site really doesn't like multiple requests.
No, no need to save the site anywhere, just use a different RegExp and modify what you need later on. I explain the 1st part here. Let us know if you need guidance on the 2nd part.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
Kotofanchik
Posts: 158
Joined: March 15th, 2024, 7:30 pm

Re: Can't pass measure value to web parser

Post by Kotofanchik »

From the very beginning I wanted to get everything and then filter it, but I realized that I didn’t know how to do it in practice, now I’ll gather my thoughts and start doing it this way. :D
User avatar
balala
Rainmeter Sage
Posts: 16549
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Can't pass measure value to web parser

Post by balala »

Yincognito wrote: June 24th, 2024, 6:51 pm Not entirely, the [mTotal] parent WebParser indeed wasn't altered, but one of its children (i.e. [mStartHour]) is or will be, due to its RegExp="(?siU)forecast valid=\".*T[mfactvalidHourcalc]:\d+:\d+\" tod(.*)$" which, as per the OP's request, "should" be using the desired non-zero hour from the fact valid=.*T(\d+):\d+:\d+\ part in the response, during the 2nd request. In this case, the manual says:

I know, it's highly redundant and personally I'd never poll a site twice in this case, since I can get all the forecast and filter it later in a different way (like described above), but well, that was the OP's idea. I was a bit unclear in my earlier reply when saying "WebParser works" - what I meant was "WebParser measures - both parent and children - work", sorry for the potential confusion.

In short, the OP wants to parse a WebParser child based on another WebParser child (if the latter is non zero). Kind of convoluted, if you ask me, but that's the idea.
Makes sense this explanation, but OMG! :yawn:
User avatar
Yincognito
Rainmeter Sage
Posts: 8153
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Can't pass measure value to web parser

Post by Yincognito »

Kotofanchik wrote: June 24th, 2024, 7:21 pm From the very beginning I wanted to get everything and then filter it, but I realized that I didn’t know how to do it in practice, now I’ll gather my thoughts and start doing it this way. :D
Sure thing - you can simplify things in a sample skin, with only the [mTotal] parent and 2 children for the 2 captures via StringIndex2 and RegExp=(?siU).*<fact valid="(.*)".*<forecast valid="\1" tod(.*)$. The 1st child / capture will be the fact valid datetime, the 2nd will be the forecast. Then you'd add an IfMatch to the 1st child to see if it has a "00" hour - if so, !SetOption a Substitute deleting everything in the 2nd child, if not, !SetOption a dummy / blank Substitute that will keep everything unchanged in the 2nd child. This should give you in the 2nd child the forecast if the fact valid hour is not zero, and nothing if the said hour is zero. If that's what you wanted, of course.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
Kotofanchik
Posts: 158
Joined: March 15th, 2024, 7:30 pm

Re: Can't pass measure value to web parser

Post by Kotofanchik »

balala wrote: June 24th, 2024, 7:23 pm Makes sense this explanation, but OMG! :yawn:
This was not a completely real task, or rather, it was the introduction of the calc measure that I was looking for why it did not work. I was looking for the problem. I compare it with zero to know when it is possible to update. Without comparison it doesn't work.
Now this is an option. A whole time stamp with a date is already entered into the parser to start the search.

Code: Select all




[mfullDate]
Measure		=Plugin
Plugin		=WebParser
Url			=[mTotal]
RegExp		="(?siU)#fullDate#"
StringIndex	=1
StringIndex2=1
IfCondition=(mfullDate > 0)
IfTrueAction=[!CommandMeasure mTotal Update]



[mvalidtime]
Measure		=Plugin
Plugin		=WebParser
Url			=[mTotal]
RegExp		="(?siU)#validtime#"
StringIndex	=1
StringIndex2=1



[DOW]
Measure=Time
TimeStampFormat=%Y-%m-%dT%H:%M:%S
TimeStamp=[mfullDate]
Format=%A
DynamicVariables=1


[mStartHour]
Measure		=Plugin
Plugin		=WebParser
Url			=[mTotal]
RegExp		="(?siU)forecast valid="[mfullDate]" tod(.*)$"
StringIndex	=1
StringIndex2=1
DynamicVariables=1
Where
[Variables]
FullDate = "fact valid="(.*)""

[DOW]
and
[mvalidtime]
This is for another task, if that.
Kotofanchik
Posts: 158
Joined: March 15th, 2024, 7:30 pm

Re: Can't pass measure value to web parser

Post by Kotofanchik »

Yincognito wrote: June 24th, 2024, 8:17 pm Sure thing - you can simplify things in a sample skin, with only the [mTotal] parent and 2 children for the 2 captures via StringIndex2 and RegExp=(?siU).*<fact valid="(.*)".*<forecast valid="\1" tod(.*)$. The 1st child / capture will be the fact valid datetime, the 2nd will be the forecast. Then you'd add an IfMatch to the 1st child to see if it has a "00" hour - if so, !SetOption a Substitute deleting everything in the 2nd child, if not, !SetOption a dummy / blank Substitute that will keep everything unchanged in the 2nd child. This should give you in the 2nd child the forecast if the fact valid hour is not zero, and nothing if the said hour is zero. If that's what you wanted, of course.
I don't fully understand. The problem is that the site gives a forecast for yesterday (not always, in this example yesterday was missing), for today and for tomorrow in three hours. I need to take the forecast only for today and tomorrow, starting from the time when the site updated the information. The only clue I saw was the time. I find time and only from this time I capture information. Now everything is working, I capture information starting from the time the information is updated on the site and not earlier, but it turns out that I will update mTotal twice, and the site gives four attempts a day (that’s what they say and after that it just stops updating the information) There may be attempts be more, but..
User avatar
Yincognito
Rainmeter Sage
Posts: 8153
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Can't pass measure value to web parser

Post by Yincognito »

Kotofanchik wrote: June 24th, 2024, 8:46 pm I don't fully understand. The problem is that the site gives a forecast for yesterday (not always, in this example yesterday was missing), for today and for tomorrow in three hours. I need to take the forecast only for today and tomorrow, starting from the time when the site updated the information. The only clue I saw was the time. I find time and only from this time I capture information. Now everything is working, I capture information starting from the time the information is updated on the site and not earlier, but it turns out that I will update mTotal twice, and the site gives four attempts a day (that’s what they say and after that it just stops updating the information) There may be attempts be more, but..
Oh, I see, now it's clearer what you want (you should have said it from the start, to be honest, because a lot depends on what exactly is the goal in the skin). Still not clear though why the comparison with 0 is needed and why it wouldn't work without it, because otherwise you could have used only the date part from a Time measure in the RegExp to grab the forecast from that date onwards, in a single request to the site... :confused:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth