It is currently March 29th, 2024, 12:28 am

WebParser stopped, no idea why

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

WebParser stopped, no idea why

Post by DanielPodo »

Hi guys, it's been a while since I've paid a visit to these forums, as I haven't had much time to dabble with Rainmeter what with life etc.

My skin's location skin has stopped giving me...well...a location. It used to work, but for a while it's just been showing nothing, no idea why.

Here's the skin code:

Code: Select all

[measureLocationParent]
Measure=WebParser
URL=https://mylocation.org/
UpdateRate=1800
RegExp=(?siU)<td>Country</td><td>(.*)</td>.*<td>City</td><td>(.*)</td>
ErrorString="There is an error!"

[measureLocationCountry]
Measure=WebParser
URL=[measureLocationParent]
StringIndex=1
Substitute="":"..."

[measureLocationCity]
Measure=WebParser
URL=[measureLocationParent]
StringIndex=2
Substitute="":"..."

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

[meterLocationIcon]
meter=Image
ImageName=#@#Images\Location\#_skin#
LeftMouseUpAction=["bingmaps://"]

[meterLocationInfo]
meter=String
MeterStyle=SmallText | BigSkinTextFormat
MeasureName=measureLocationCity
MeasureName2=measureLocationCountry
Text=%1#CRLF#%2
FYI City is not showing up, so that's expected, but I should still get the country showing up (Poland, where I'm currently based).

Any help would be greatly appreciated!!!
User avatar
Yincognito
Rainmeter Sage
Posts: 7029
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: WebParser stopped, no idea why

Post by Yincognito »

DanielPodo wrote: March 10th, 2020, 3:14 pm Hi guys, it's been a while since I've paid a visit to these forums, as I haven't had much time to dabble with Rainmeter what with life etc.

My skin's location skin has stopped giving me...well...a location. It used to work, but for a while it's just been showing nothing, no idea why.

Here's the skin code:

[...]

FYI City is not showing up, so that's expected, but I should still get the country showing up (Poland, where I'm currently based).

Any help would be greatly appreciated!!!
Well, if you replace your code with this (make a backup first):

Code: Select all

[Variables]

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

---Measures---

[measureLocationParent]
Measure=WebParser
URL=https://mylocation.org/
UpdateRate=1800
;RegExp=(?siU)<td>Country</td><td>(.*)</td>.*<td>City</td><td>(.*)</td>
RegExp=(?siU)^(.*)$
;ErrorString="There is an error!"

[measureLocationCountry]
Measure=WebParser
URL=[measureLocationParent]
StringIndex=1
Substitute="":"..."

[measureLocationCity]
Measure=WebParser
URL=[measureLocationParent]
StringIndex=2
Substitute="":"..."

---Meters---

[MeterAutoLocateDemo]
Meter=STRING
X=5
Y=5
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
MeasureName=measureLocationCity
MeasureName2=measureLocationCountry
Text=%1#CRLF#%2
;DynamicVariables=1
you'll see why. Apparently the site returns a "403 Forbidden" error. By the way, the site isn't too precise either: it's off with a couple of dozen kms in my case, so you may want to switch to a different one, like:

Code: Select all

[Variables]
Language=en-GB
URLCurrent=""

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

---Measures---

[MeasureLocationGeocode]
Measure=WebParser
URL=https://ipapi.co/json
RegExp="(?siU).*"city": (.*),.*"country_name": (.*),.*"
UpdateRate=600
FinishAction=[!UpdateMeasureGroup GeocodeGroup]
DynamicVariables=1

[MeasureCity]
Group=GeocodeGroup
Measure=WebParser
URL=[MeasureLocationGeocode]
StringIndex=1
UpdateDivider=-1

[MeasureCountry]
Group=GeocodeGroup
Measure=WebParser
URL=[MeasureLocationGeocode]
StringIndex=2
UpdateDivider=-1

---Meters---

[MeterAutoLocateDemo]
Meter=STRING
X=5
Y=5
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
MeasureName=MeasureCity
MeasureName2=MeasureCountry
Text="City    = %1#CRLF#Country = %2"
DynamicVariables=1
That's about it. If anyone has another solution for it (maybe changing the WebParser UserAgent or Header could help?), feel free to post it.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: WebParser stopped, no idea why

Post by balala »

EDIT: Sorry, Yincognito beat me. Again!
DanielPodo wrote: March 10th, 2020, 3:14 pm FYI City is not showing up, so that's expected, but I should still get the country showing up (Poland, where I'm currently based).

Any help would be greatly appreciated!!!
You have to do two things:
  • The RegExp option of the [measureLocationParent] measure is wrong. Try the following form: RegExp=(?siU)<td>Country</td>.*<td>(.*)</td>.*<td>City</td>.*<td>(.*)</td> (marked red what have been missing).
  • Add a UserAgent=Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0 to the same [measureLocationParent] measure.
Does it work with these updates?
User avatar
Yincognito
Rainmeter Sage
Posts: 7029
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: WebParser stopped, no idea why

Post by Yincognito »

balala wrote: March 10th, 2020, 4:05 pmEDIT: Sorry, Yincognito beat me. Again!
Sorry about that - I'm getting faster day by day, apparently ... :lol:
At least you've identified the actual solution (and the mistakes in the code), so it's ok. And yes, your code works for me - hopefully for the OP as well.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: WebParser stopped, no idea why

Post by balala »

Yincognito wrote: March 10th, 2020, 4:16 pm I'm getting faster day by day, apparently ...
Congratulations, this is a good thing, I think.
User avatar
Yincognito
Rainmeter Sage
Posts: 7029
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: WebParser stopped, no idea why

Post by Yincognito »

balala wrote: March 10th, 2020, 4:23 pm Congratulations, this is a good thing, I think.
Only if it doesn't affect efficiency and accuracy. If it does, I prefer being slower and accurate than fast and inaccurate.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: WebParser stopped, no idea why

Post by balala »

Yincognito wrote: March 10th, 2020, 4:59 pm Only if it doesn't affect efficiency and accuracy. If it does, I prefer being slower and accurate than fast and inaccurate.
User avatar
DanielPodo
Posts: 77
Joined: March 30th, 2016, 1:50 pm

Re: WebParser stopped, no idea why

Post by DanielPodo »

Yincognito wrote: March 10th, 2020, 4:00 pm
...
you'll see why. Apparently the site returns a "403 Forbidden" error.
I actually did not get that, I just got the html code :rolmfao:
Balala wrote:You have to do two things:
The RegExp option of the [measureLocationParent] measure is wrong. Try the following form: RegExp=(?siU)<td>Country</td>.*<td>(.*)</td>.*<td>City</td>.*<td>(.*)</td> (marked red what have been missing).
I literally had the same code earlier today, it's what I used when it worked, so I changed it assuming that maybe I had accidentally edited something at some point and made a mess of it, so I tried from scratch again. However, it still didn't work until I added...
Balala wrote:Add a UserAgent=Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0 to the same [measureLocationParent] measure.
My guess is with the updated Rainmeter, this is required?
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: WebParser stopped, no idea why

Post by balala »

DanielPodo wrote: March 10th, 2020, 9:38 pm I literally had the same code earlier today, it's what I used when it worked, so I changed it assuming that maybe I had accidentally edited something at some point and made a mess of it, so I tried from scratch again. However, it still didn't work until I added...
No, you didn't rewrite anything, neither accidentally, nor other way. Probably the HTML code of the site has been rewritten in meantime. Some sites are capable to check what program try to access them and refuse to work if that program is not a browser. Adding the UserAgent option you "mislead" the site.
Glad if you got it working.
User avatar
Yincognito
Rainmeter Sage
Posts: 7029
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: WebParser stopped, no idea why

Post by Yincognito »

DanielPodo wrote: March 10th, 2020, 9:38 pm I actually did not get that, I just got the html code :rolmfao:
Lucky bastard... :rolmfao:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth