It is currently April 27th, 2024, 5:31 pm

Webparser not working...

Get help with creating, editing & fixing problems with skins
User avatar
DanielPodo
Posts: 77
Joined: March 30th, 2016, 1:50 pm

Webparser not working...

Post by DanielPodo »

Hi all...been a while. I used to lurk here a lot more back in the day but unfortuately life really went downhill since 2017 and to cut a long story short, I went to hell and back.

Luckily I'm on the mend again and I'm slowly returning to things that I used to fondly spend time doing all those years ago. So I decided to give a few of my unfinished skins a go and felt like finishing one off, sort of inspired by the android designs over the years.

Before I post it in the skins section, any idea why this webparser isn't working? :?

Everything works apart from the measureWAN measure. It doesn't parse the html code and I can't figure out why...given that I've given rainmeter a break for around 6 years it could be something fundamental that I've forgotten, but after a couple of hours online I can't seem to diagnose the issue.

Thanks in advance!

Code: Select all

[measureConnection]
Measure=SysInfo
SysInfoType=INTERNET_CONNECTIVITY
Substitute="-1":"#_skinOff#","1":"#_skinOn#","0":"zWait"
IfCondition=measureConnection=-1
IfTrueAction=!SetTransparency 100
IfFalseAction=!SetTransparency 255
OnChangeAction=[!UpdateMeasure measureWAN][!Refresh]

[measureWAN]
Measure=WebParser
Url=https://www.whatismyip.com/
RegExp=(?siU)<span class="the-ipv4">(.*)</span>
StringIndex=1
Substitute="":"No connection"
UpdateRate=3600

[measureGateway]
Measure=SysInfo
SysInfoData=Best
SysInfoType=GATEWAY_ADDRESS
Substitute="":"N/A"
UpdateDivider=-1

; ----------------------------------
; METERS
; ----------------------------------

[meterConnectionIcon]
Meter=Image
MeasureName=measureConnection
ImagePath=#@#Images\Network\
LeftMouseUpAction=[Shell:::{8E908FC9-BECC-40f6-915B-F4CA0E70D03D}]
DynamicVariables=1

[meterNetworkInfo]
Meter=String
MeterStyle=SmallText | BigSkinTextFormat
MeasureName=measureWAN
MeasureName2=measureGateway
Text=%1#CRLF#%2
User avatar
CodeCode
Posts: 1366
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Webparser not working...

Post by CodeCode »

Try to add DynamicVariables=1 to your wanip measure?
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
Yincognito
Rainmeter Sage
Posts: 7178
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Webparser not working...

Post by Yincognito »

DanielPodo wrote: January 22nd, 2024, 11:29 pm Hi all...been a while. I used to lurk here a lot more back in the day but unfortuately life really went downhill since 2017 and to cut a long story short, I went to hell and back.

Luckily I'm on the mend again and I'm slowly returning to things that I used to fondly spend time doing all those years ago. So I decided to give a few of my unfinished skins a go and felt like finishing one off, sort of inspired by the android designs over the years.

Before I post it in the skins section, any idea why this webparser isn't working? :?

Everything works apart from the measureWAN measure. It doesn't parse the html code and I can't figure out why...given that I've given rainmeter a break for around 6 years it could be something fundamental that I've forgotten, but after a couple of hours online I can't seem to diagnose the issue.

Thanks in advance!

Code: Select all

[measureConnection]
Measure=SysInfo
SysInfoType=INTERNET_CONNECTIVITY
Substitute="-1":"#_skinOff#","1":"#_skinOn#","0":"zWait"
IfCondition=measureConnection=-1
IfTrueAction=!SetTransparency 100
IfFalseAction=!SetTransparency 255
OnChangeAction=[!UpdateMeasure measureWAN][!Refresh]

[measureWAN]
Measure=WebParser
Url=https://www.whatismyip.com/
RegExp=(?siU)<span class="the-ipv4">(.*)</span>
StringIndex=1
Substitute="":"No connection"
UpdateRate=3600

[measureGateway]
Measure=SysInfo
SysInfoData=Best
SysInfoType=GATEWAY_ADDRESS
Substitute="":"N/A"
UpdateDivider=-1

; ----------------------------------
; METERS
; ----------------------------------

[meterConnectionIcon]
Meter=Image
MeasureName=measureConnection
ImagePath=#@#Images\Network\
LeftMouseUpAction=[Shell:::{8E908FC9-BECC-40f6-915B-F4CA0E70D03D}]
DynamicVariables=1

[meterNetworkInfo]
Meter=String
MeterStyle=SmallText | BigSkinTextFormat
MeasureName=measureWAN
MeasureName2=measureGateway
Text=%1#CRLF#%2
Nice to see you're back on form. :great:
You might want to:
- check if the site still works
- check if the regex pattern is appropriate
- precede regex reserved chars like / with a \ to escape them
Other than that, the code looks fine, though I didn't test it. One more thing: it makes no sense to update anything before refreshing, since the latter already does that.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
DanielPodo
Posts: 77
Joined: March 30th, 2016, 1:50 pm

Re: Webparser not working...

Post by DanielPodo »

Yincognito wrote: January 23rd, 2024, 1:27 pm Nice to see you're back on form. :great:
You might want to:
- check if the site still works
- check if the regex pattern is appropriate
- precede regex reserved chars like / with a \ to escape them
Other than that, the code looks fine, though I didn't test it. One more thing: it makes no sense to update anything before refreshing, since the latter already does that.
> check if the site still works

It does.

> check if the regex pattern is appropriate

According to https://regex101.com/, yes it does (though it told me to escape the slash in the closing span bracket but still, even with that fixed, nothing works.

> precede regex reserved chars like / with a \ to escape them

As above.

> One more thing: it makes no sense to update anything before refreshing, since the latter already does that.

Ah, thanks!
User avatar
Yincognito
Rainmeter Sage
Posts: 7178
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Webparser not working...

Post by Yincognito »

DanielPodo wrote: January 23rd, 2024, 1:49 pm > check if the site still works

It does.

> check if the regex pattern is appropriate

According to https://regex101.com/, yes it does (though it told me to escape the slash in the closing span bracket but still, even with that fixed, nothing works.

> precede regex reserved chars like / with a \ to escape them

As above.

> One more thing: it makes no sense to update anything before refreshing, since the latter already does that.

Ah, thanks!
Alright, thanks for letting us know. I'll test the code in a couple of moments to see what can be done about it.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
DanielPodo
Posts: 77
Joined: March 30th, 2016, 1:50 pm

Re: Webparser not working...

Post by DanielPodo »

CodeCode wrote: January 23rd, 2024, 2:39 am Try to add DynamicVariables=1 to your wanip measure?
No but it still doesn't solve the problem, sadly.
User avatar
DanielPodo
Posts: 77
Joined: March 30th, 2016, 1:50 pm

Re: Webparser not working...

Post by DanielPodo »

Yincognito wrote: January 23rd, 2024, 1:53 pm Alright, thanks for letting us know. I'll test the code in a couple of moments to see what can be done about it.
If it helps, I checked the rainmeter log and it says "RegExp matching error (-1)".
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5407
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Webparser not working...

Post by eclectic-tech »

From my tests it appears 'whatismyip.com' is using java scripts to show your address, and does not contain the IP address TEXT anywhere the Webparser can access...

I tried a different site : 'showmyip.com' and changed the RegExp. With this site I was able to parse the IP address.

Try this modified measure and see if it works for you.

Code: Select all

[measureWAN]
Measure=WebParser
UserAgent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36 Edg/92.0.902.84
Flags=ForceReload | NoCookies
; Url=file://webparserdump.txt
Url=https://www.showmyip.com/
; Url=https://www.whatismyip.com/
RegExp=(?siU)<h2 id="ipv4">(.*)</h2>
StringIndex=1
Substitute="":"No connection"
UpdateRate=3600
; Debug=2
User avatar
Yincognito
Rainmeter Sage
Posts: 7178
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Webparser not working...

Post by Yincognito »

Just to confirm, eclectic-tech is right, the IPs provided by the site you were using are hidden behind their corresponding Javascript retrieval functions, so you won't be able to get them by parsing the page source. Changing the site is the best option, unless you want to register and get 24 free calls per day as per their API, which will provide data in a Javascript free text form that can be retrieved by WebParser:
https://www.whatismyip.com/api/
Obviously, 24 calls per day could be insufficient and most likely not suited unless you're looking for rare, personal usage of these features.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
DanielPodo
Posts: 77
Joined: March 30th, 2016, 1:50 pm

Re: Webparser not working...

Post by DanielPodo »

I tried a few websites like the one I was using and I guess they all use JS to generate the IP, causing the issue as I originally described.
Try this modified measure and see if it works for you.
Thanks! That works!

While I'm at it, my old weather skin isn't working either, I'm guessing the same issue (plus it's been 4-5 years since I last used the skin). Is there a website you guys can recommend?