It is currently April 26th, 2024, 11:06 am

Webparser returns an empty response

Get help with creating, editing & fixing problems with skins
TomYork1986
Posts: 3
Joined: January 10th, 2023, 7:01 am

Webparser returns an empty response

Post by TomYork1986 »

Hello, community! Need your help.

I'm trying to create my own skin and get weather data using webparser plugin. For some reasons ot doesn't work. It returns an empty response. In log file:

Code: Select all

DBUG (10:07:17.596) tick weather v2\weather.ini - [Current]: Fetching: http://api.open-meteo.com/v1/forecast?latitude=51.5287718&longitude=-0.2416807&current_weather=true
DBUG (10:07:17.726) tick weather v2\weather.ini - [Current]: Fetching: Success!
DBUG (10:07:17.730) tick weather v2\weather.ini - [Current]: Parsing data...
ERRO (10:07:17.733) tick weather v2\weather.ini - [Current]: RegExp matching error (-1)
DBUG (10:07:17.736) tick weather v2\weather.ini - [Current]: Parsing data...done!
But if I set Debug=2 it creates file with server response (WebParserDump):

Code: Select all

{"latitude":51.52,"longitude":-0.24000025,"generationtime_ms":0.21696090698242188,"utc_offset_seconds":0,"timezone":"GMT","timezone_abbreviation":"GMT","elevation":33.0,"current_weather":{"temperature":5.4,"windspeed":7.3,"winddirection":171.0,"weathercode":61,"time":"2023-01-10T07:00"}}
My skin code:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
--------------------------------------------------------------------------------------------------------------
[Current]
Measure=Plugin
Plugin=WebParser.dll
UpdateRate=600
URL=http://api.open-meteo.com/v1/forecast?latitude=51.5287718&longitude=-0.2416807&current_weather=true
RegExp=(?siU)temperature":"(.*)"
--------------------------------------------------------------------------------------------------------------
[MeasureWeatherTemp]
Measure=Plugin
Plugin=WebParser.dll
Url=[Current]
StringIndex=1
--------------------------------------------------------------------------------------------------------------
[MeterTemp]
MeasureName=MeasureWeatherTemp
Meter=STRING
X=32
Y=150
FontColor=ffffff
FontSize=17
StringAlign=Center
FontFace=Segoe UI
Antialias=1
Postfix="°C"

[MeterDay]
Meter=STRING
X=32
Y=40
FontColor=255, 255, 255, 220
FontSize=14
StringAlign=Center
FontFace=Segoe UI
Text="Today"
Antialias=1
Environment:
Rainmeter 4.5.17.3700 (64-bit)
Windows 10 Pro 21H2 (build 19044.2364) 64-bit
User avatar
ikarus1969
Posts: 571
Joined: February 28th, 2011, 3:20 pm
Location: Vienna, Austria

Re: Webparser returns an empty response

Post by ikarus1969 »

The temperature itself isn't enclosed in double-quotes so as a first try i would adapt the regular-expression in the [Current]-measure like that:

Code: Select all

RegExp=(?siU)temperature":(.*),"
Last edited by ikarus1969 on January 10th, 2023, 11:40 am, edited 2 times in total.
User avatar
ikarus1969
Posts: 571
Joined: February 28th, 2011, 3:20 pm
Location: Vienna, Austria

Re: Webparser returns an empty response

Post by ikarus1969 »

I just tried it and it works the way i suggested
TomYork1986
Posts: 3
Joined: January 10th, 2023, 7:01 am

Re: Webparser returns an empty response

Post by TomYork1986 »

Oh my! Works like a charm! Thank you very much!
User avatar
ikarus1969
Posts: 571
Joined: February 28th, 2011, 3:20 pm
Location: Vienna, Austria

Re: Webparser returns an empty response

Post by ikarus1969 »

You're welcome! Have fun with rainmeter - and thanks for pointing me to a really interesting website with your post (open-meteo.com)
User avatar
balala
Rainmeter Sage
Posts: 16172
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Webparser returns an empty response

Post by balala »

TomYork1986 wrote: January 10th, 2023, 7:14 am My skin code:
Apart from ikarus1969's solution, which is good and there is nothing to comment related to it, you should have to note that WebParser has ceased to be a plugin long time ago. It was indeed a plugin once, but in meantime it became an internal measure and should be treated accordingly, even if for backward compatibility reasons the plugin approach still works. So, you should replace all occurrences of the Measure=Plugin and Plugin=WebParser.dll options pairs by the simpler Measure=WebParser option.
TomYork1986
Posts: 3
Joined: January 10th, 2023, 7:01 am

Re: Webparser returns an empty response

Post by TomYork1986 »

Thank you for advice! Took this into account.