It is currently March 29th, 2024, 12:34 pm

WebParser WeatherRss RegExp help

Get help with creating, editing & fixing problems with skins
pepperhole
Posts: 5
Joined: December 15th, 2017, 1:25 pm

WebParser WeatherRss RegExp help

Post by pepperhole »

Hi,

I'm using webparser plugin with wxdata.weather.com to get temperature and weather icon. The problem is weather icon code is not provided for my location. However in the today in the next 6 days forecast icon code is provided. So I need help editing regexp to get correct icon code.

If I open the url in chrome the <icon> value is missing under <cc> section. I recon this is the one parsed by the regexp.
I need to add the <icon> value from <dayf> <day d=0 t="Friday" dt="Dec 15"> <part p=d> <icon>.


Current url and regexp:

Code: Select all

Url=http://wxdata.weather.com/wxdata/weather/local/NOXX0218?cc=*&unit=M&dayf=6
RegExp="(?siU).*<locale>(.*)</locale>.*<ut>(.*)</ut>.*<ud>(.*)</ud>.*<us>(.*)</us>.*<up>(.*)</up>.*<ur>(.*)</ur>.*<loc id="(.*)">.*<dnam>(.*)</dnam>.*<tm>(.*)</tm>.*<lat>(.*)</lat>.*<lon>(.*)</lon>.*<sunr>(.*)</sunr>.*<suns>(.*)</suns>.*<zone>(.*)</zone>.*<cc>.*<lsup>(.*)</lsup>.*<obst>(.*)</obst>.*<tmp>(.*)</tmp>.*<flik>(.*)</flik>.*<t>(.*)</t>.*<icon>(.*)</icon>.*<bar>.*<r>(.*)</r>.*<d>(.*)</d>.*<wind>.*<s>(.*)</s>.*<gust>(.*)</gust>.*<d>(.*)</d>.*<t>(.*)</t>.*<hmid>(.*)</hmid>.*<vis>(.*)</vis>.*<uv>.*<i>(.*)</i>.*<t>(.*)</t>.*<dewp>(.*)</dewp>.*<moon>.*<icon>(.*)</icon>.*<t>(.*)</t>.*"
Debug log file:

Code: Select all

DBUG (14:29:09.515) System Info\System Info.ini - [mWeatherRSS]: Fetching: http://wxdata.weather.com/wxdata/weather/local/NOXX0218?cc=*&unit=M&dayf=6
DBUG (14:29:09.970) System Info\System Info.ini - [mWeatherRSS]: Index  0: <weather ver="2.0">
        <head>
      <locale>en_US</locale>
      <form>MEDIUM</form>
      <ut>C</ut>
      <ud>km</ud>
      <us>km/h</us>
      <up>mb</up>http://wxdata.weather.com/wxdata/weather/local/NOXX0218?cc=*&unit=M&dayf=6
      <ur>mm</ur>
    </head>
        <loc id="NOXX0218">
      <dnam>Honningsvag, 20, Norway
DBUG (14:29:09.978) System Info\System Info.ini - [mWeatherRSS]: Index  1: en_US
DBUG (14:29:09.986) System Info\System Info.ini - [mWeatherRSS]: Index  2: C
DBUG (14:29:09.993) System Info\System Info.ini - [mWeatherRSS]: Index  3: km
DBUG (14:29:10.001) System Info\System Info.ini - [mWeatherRSS]: Index  4: km/h
DBUG (14:29:10.009) System Info\System Info.ini - [mWeatherRSS]: Index  5: mb
DBUG (14:29:10.017) System Info\System Info.ini - [mWeatherRSS]: Index  6: mm
DBUG (14:29:10.025) System Info\System Info.ini - [mWeatherRSS]: Index  7: NOXX0218
DBUG (14:29:10.033) System Info\System Info.ini - [mWeatherRSS]: Index  8: Honningsvag, 20, Norway
DBUG (14:29:10.041) System Info\System Info.ini - [mWeatherRSS]: Index  9: 2:29 PM
DBUG (14:29:10.049) System Info\System Info.ini - [mWeatherRSS]: Index 10: 70.98
DBUG (14:29:10.057) System Info\System Info.ini - [mWeatherRSS]: Index 11: 25.97
DBUG (14:29:10.064) System Info\System Info.ini - [mWeatherRSS]: Index 12: 
DBUG (14:29:10.072) System Info\System Info.ini - [mWeatherRSS]: Index 13: 
DBUG (14:29:10.080) System Info\System Info.ini - [mWeatherRSS]: Index 14: 1
DBUG (14:29:10.087) System Info\System Info.ini - [mWeatherRSS]: Index 15: 12/15/17 2:00 PM CET
DBUG (14:29:10.094) System Info\System Info.ini - [mWeatherRSS]: Index 16: Honningsvag, 20, NO
DBUG (14:29:10.101) System Info\System Info.ini - [mWeatherRSS]: Index 17: -1
DBUG (14:29:10.108) System Info\System Info.ini - [mWeatherRSS]: Index 18: -8
DBUG (14:29:10.115) System Info\System Info.ini - [mWeatherRSS]: Index 19: 
DBUG (14:29:10.123) System Info\System Info.ini - [mWeatherRSS]: Index 20: 
DBUG (14:29:10.130) System Info\System Info.ini - [mWeatherRSS]: Index 21: 992.89
DBUG (14:29:10.137) System Info\System Info.ini - [mWeatherRSS]: Index 22: falling rapidly
DBUG (14:29:10.144) System Info\System Info.ini - [mWeatherRSS]: Index 23: 35
DBUG (14:29:10.151) System Info\System Info.ini - [mWeatherRSS]: Index 24: N/A
DBUG (14:29:10.159) System Info\System Info.ini - [mWeatherRSS]: Index 25: 180
DBUG (14:29:10.166) System Info\System Info.ini - [mWeatherRSS]: Index 26: S
DBUG (14:29:10.174) System Info\System Info.ini - [mWeatherRSS]: Index 27: 75
DBUG (14:29:10.182) System Info\System Info.ini - [mWeatherRSS]: Index 28: 
DBUG (14:29:10.189) System Info\System Info.ini - [mWeatherRSS]: Index 29: 0
DBUG (14:29:10.196) System Info\System Info.ini - [mWeatherRSS]: Index 30: Low
DBUG (14:29:10.203) System Info\System Info.ini - [mWeatherRSS]: Index 31: -5
DBUG (14:29:10.210) System Info\System Info.ini - [mWeatherRSS]: Index 32: 27
DBUG (14:29:10.217) System Info\System Info.ini - [mWeatherRSS]: Index 33: Waning Crescent
Thanks in advance!
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: WebParser WeatherRss RegExp help

Post by balala »

Do you know since when the number of the icon is missing? I suppose you shouldn't have to edit the code yet, because many times the provider encounters such problems, but many times these problems gets fixed quickly .
So, I'd wait a few days, to see if they fix the issue.
pepperhole
Posts: 5
Joined: December 15th, 2017, 1:25 pm

Re: WebParser WeatherRss RegExp help

Post by pepperhole »

Missing since I set it up today. Thanks for the info. I'll wait a few days and see.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: WebParser WeatherRss RegExp help

Post by balala »

pepperhole wrote:Missing since I set it up today. Thanks for the info. I'll wait a few days and see.
Ok, wait let's say a week, then if it still doesn't work, please come back.
pepperhole
Posts: 5
Joined: December 15th, 2017, 1:25 pm

Re: WebParser WeatherRss RegExp help

Post by pepperhole »

The icon still doesn't work. I'm not a stranger to coding at all, but for some reason I've never managed to wrap my head around regex. If someone can help me it will be much appreciated.

Here is the complete code used for temperature and icon.

Code: Select all

[mWeatherRSS]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=1600
Url=http://wxdata.weather.com/wxdata/weather/local/NOXX0218?cc=*&unit=M&dayf=6
RegExp="(?siU).*<locale>(.*)</locale>.*<ut>(.*)</ut>.*<ud>(.*)</ud>.*<us>(.*)</us>.*<up>(.*)</up>.*<ur>(.*)</ur>.*<loc id="(.*)">.*<dnam>(.*)</dnam>.*<tm>(.*)</tm>.*<lat>(.*)</lat>.*<lon>(.*)</lon>.*<sunr>(.*)</sunr>.*<suns>(.*)</suns>.*<zone>(.*)</zone>.*<cc>.*<lsup>(.*)</lsup>.*<obst>(.*)</obst>.*<tmp>(.*)</tmp>.*<flik>(.*)</flik>.*<t>(.*)</t>.*<icon>(.*)</icon>.*<bar>.*<r>(.*)</r>.*<d>(.*)</d>.*<wind>.*<s>(.*)</s>.*<gust>(.*)</gust>.*<d>(.*)</d>.*<t>(.*)</t>.*<hmid>(.*)</hmid>.*<vis>(.*)</vis>.*<uv>.*<i>(.*)</i>.*<t>(.*)</t>.*<dewp>(.*)</dewp>.*<moon>.*<icon>(.*)</icon>.*<t>(.*)</t>.*"
StringIndex=1
IfAboveValue=1
IfAboveAction=!execute [!RainmeterHideMeter mWeatherDesc][!RainmeterHideMeter mWeatherTemp][!RainmeterShowMeter MeterText]
;Debug=1

[mWeatherTemp]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[mWeatherRSS]
StringIndex=17

[mIcon]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[mWeatherRSS]
StringIndex=20

[MeterTemp]
MeasureName=mWeatherTemp
Meter=STRING
X=550
Y=-3
FontSize=18
MeterStyle=Style01
StringAlign=Left
FontSize=18
AntiAlias=1
Antialias=1
Postfix=°

[MeterIcon]
MeasureName=mIcon
Meter=IMAGE
X=570
Y=-12
w=60
h=44
Antialias=1
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: WebParser WeatherRss RegExp help

Post by balala »

pepperhole wrote:The icon still doesn't work. I'm not a stranger to coding at all, but for some reason I've never managed to wrap my head around regex. If someone can help me it will be much appreciated.
Right now your code returned -1 for the temperature (probably the temperature there, in Celsius degrees). For the icon, it didn't return nothing, but at least the code works, giving no errors at all. Please check if it also does for you.
pepperhole
Posts: 5
Joined: December 15th, 2017, 1:25 pm

Re: WebParser WeatherRss RegExp help

Post by pepperhole »

balala wrote:Right now your code returned -1 for the temperature (probably the temperature there, in Celsius degrees). For the icon, it didn't return nothing, but at least the code works, giving no errors at all. Please check if it also does for you.
Same for me. Index 20 which is the icon is empty. As I wrote in the first post I need to add the icon value from today from the 6 days forecast to the array. Try to open the URL in chrome and you'll see that icon value is present. Here is a screenshot with the icon value at the bottom. With editing the regexp it should be possible to add this to the array.
https://imgur.com/a/k7FDM
pepperhole
Posts: 5
Joined: December 15th, 2017, 1:25 pm

Re: WebParser WeatherRss RegExp help

Post by pepperhole »

I fixed it!

Found a tool called RainRegExp which helps build and debug regex.

Here is the solution in case anyone stumbles upon this later. Needed to add this to the end of RegExp:

Code: Select all

.*<dayf>.*<day d="0".*>.*<part p="n">.*<icon>(.*)</icon>
And then change mIcon (icon measure) to use StringIndex=34
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: WebParser WeatherRss RegExp help

Post by balala »

pepperhole wrote:I fixed it!

Found a tool called RainRegExp which helps build and debug regex.

Here is the solution in case anyone stumbles upon this later. Needed to add this to the end of RegExp:

Code: Select all

.*<dayf>.*<day d="0".*>.*<part p="n">.*<icon>(.*)</icon>
And then change mIcon (icon measure) to use StringIndex=34
:17good
Ok, I'm glad if you got it working well. Congratulations for the fix.