Code: Select all
(?siU)<dt>(.*)<\/dt>(?(?<=Dothan)<dt>(.*)<\/dt>)
Code: Select all
(?siU)<dt>(.*)<\/dt>(?(?<=Dothan)<dt>(.*)<\/dt>)
Something like this:
Code: Select all
[Variables]
Location=Dothan
[MeasureRainmeter]
Measure=WebParser
UpdateRate=3600
Url=https://weather.codes/united-states-of-america/alabama/
RegExp=(?siU)</dd><dt>(.{8})</dt><dd>#Location#\r
[MeasureWeatherCode]
Measure=WebParser
Url=[MeasureRainmeter]
StringIndex=1
(.{8}) means there are exactly 8 characters in the weather code. Not more, nor less.
Fixed.
Code: Select all
[Variables]
Location=Dothan
[MeasureExists]
Measure=WebParser
UpdateRate=3600
Url=https://weather.codes/united-states-of-america/alabama/
RegExp=(?siU)(?(?=.*#Location#)(.*)\r)
IfMatch=^$
IfMatchAction=[!DisableMeasure "MeasureRainmeter"]
IfNotMatchAction=[!EnableMeasure "MeasureRainmeter"][!CommandMeasure "MeasureRainmeter" "Update"]
StringIndex=1
[MeasureRainmeter]
Measure=WebParser
UpdateRate=3600
Url=https://weather.codes/united-states-of-america/alabama/
RegExp=(?siU)</dd><dt>(.{8})</dt><dd>#Location#\r
Disabled=1
[MeasureWeatherCode]
Measure=WebParser
Url=[MeasureRainmeter]
StringIndex=1
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
Blur=1
[Variables]
@Include=#@#var.inc
[MeasureLocation]
Measure=Plugin
Plugin=WebParser
Url=http://api.ipstack.com/check?access_key=###API_KEY_REMOVED###&format=1
RegExp=(?siU)"country_name":"(.*)".*"region_name":"(.*)".*"city":"(.*)".*
UpdateRate=-1
FinishAction=[!Showmeter "MeterChange"]
[MeasureRegion]
Measure=Plugin
Plugin=WebParser
URL=[MeasureLocation]
StringIndex=2
Substitute="A":"a","B":"b","C":"c","D":"d","E":"e","F":"f","G":"g","H":"h","I":"i","J":"j","K":"k","L":"l","M":"m","N":"n","O":"o","P":"p","Q":"q","R":"r","S":"s","T":"t","U":"u","V":"v","W":"w","X":"x","Y":"y","Z":"z"
[MeasureCity]
Measure=Plugin
Plugin=WebParser
URL=[MeasureLocation]
StringIndex=3
[MeasureCountry]
Measure=Plugin
Plugin=WebParser
URL=[MeasureLocation]
StringIndex=1
IfMatch=United States
IfMatchAction=[!SetVariable mUrl "https://weather.codes/united-states-of-america/#Region#/"][!SetVariable mRegExp "(?siU)<dt>(.{8})</dt><dd>#City#\r"]
IfNotMatchAction=[!SetVariable mUrl "https://weather.codes/search/?q=#City#"][!SetVariable mRegExp ""]
[BGblur]
Meter=Image
W=300
H=150
SolidColor=0,0,0,100
[MeterCity]
Meter=String
MeasureName=MeasureCity
AntiAlias=1
FontColor=255,255,255
FontSize=14
X=150
Y=50
StringAlign=CenterCenter
[MeterChange]
Meter=String
AntiAlias=1
FontColor=255,255,255
FontSize=10
Text="Click here if it's your city"
X=r
Y=R
StringAlign=Center
DynamicVariables=1
Hidden=1
LeftMouseDownAction=[!WriteKeyValue Variables Country [MeasureCountry] "#@#var.inc"][!WriteKeyValue Variables Region [MeasureRegion] "#@#var.inc"][!WriteKeyValue Variables City [MeasureCity] "#@#var.inc"][!UpdateMeasure "MeasureWeatherCode"][!Refresh]
[MeasureWeatherCode]
Measure=Plugin
Plugin=WebParser
URL=#mUrl#
RegExp=#mRegExp#
;URL=https://weather.codes/united-states-of-america/#Region#/
;RegExp=(?siU)<dt>(.{8})</dt><dd>#City#\r
UpdateRate=-1
FinishAction=[!HideMeter MeterChange][!Showmeter "MeterCode"]
[MeasureCode]
Measure=Plugin
Plugin=WebParser
URL=[MeasureWeatherCode]
StringIndex=1
[MeterCode]
Meter=String
MeasureName=MeasureCode
FontColor=255,255,255
AntiAlias=1
FontSize=12
Text=%1
X=r
Hidden=1
Y=R
StringAlign=Center
It is hard to tell exactly, because I don't have the var.inc file, but most probably you have to add a DynamicVariables=1 option to the [MeasureWeatherCode] measure. This is needed because the measure uses variables created / modified dynamically, which require to set the dynamic variables. I would also remove the UpdateRate=-1 option from the same [MeasureWeatherCode] measure. Doesn't seem a good idea to use such an option on WebParser measures.
Doesn't work? I suppose it doesn't and this because when you set values for the mUrl and mRegExp variables (through the IfMatchAction and IfNotMatchAction options of the [MeasureCountry] measure), you also should update the [MeasureWeatherCode] measure. Add the following two bangs to the end of both options, IfMatchActionand and IfNotMatchAction: [!UpdateMeasure "MeasureWeatherCode"][!CommandMeasure "MeasureWeatherCode" "Update"].