[Solved]Counting items
Posted: October 21st, 2016, 5:47 pm
I'm trying to create a lua files that counts how many "Others" are present in a file, but only if they are in the <span class= "Title">. The problem is that sometimes there is another <span class="Title" etc>, then how do I count only the "Others" under <span class="Title"> if there is or there is not another <span class = "Title" etc>?
skin.ini
SomeFile.txt
count.lua
skin.ini
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
[MeasureSite]
Measure=Plugin
Plugin=WebParser
URL=file://#CURRENTPATH#SomeFile.txt
RegExp=(?siU)^(.*)$
UpdateRate=60000
FinishAction=[!UpdateMeasure MeasureScript]
[MeasureScript]
Measure=Script
ScriptFile=count.lua
UpdateDivider=-1
[MeterString]
Meter=String
Code: Select all
<div class="Today">A Name HERE</div><div class="Type" style="padding-top:5px">A TYPE HERE</div>
<span class="Title">A TITLE HERE</span><br /><br />
<span class="Others" style="margin-bottom: 10px;">Name ONE<br /><i style="font-weight:normal;margin-left: 20px;">Type ONE</i></span><br /><span class="Others" style="margin-bottom: 10px;">Name TWO<br /><i style="font-weight:normal;margin-left: 20px;">Type TWO</i></span><br /><span class="Others" style="margin-bottom: 10px;">Name THREE<br /><i style="font-weight:normal;margin-left: 20px;">Type THREE</i></span><br /><span class="Title" style="clear: both;margin-top: 20px;margin-bottom: 20px;">ANOTHER TITLE HERE</span><br /><br /> <span class="Others" style="margin-bottom: 10px;"><a style="float:left" href="DATE">DATE ONE</a><span style="float:left">: </span><span style="float:left; width:370px; margin-left:3px">Name FOUR<br /><i style="font-weight:normal;margin-left: 20px">Type FOUR</i></span></span></span><br /><span class="Others" style="margin-bottom: 10px;"><a style="float:left" href="DATE 2">DATE TWO</a><span style="float:left">: </span><span style="float:left; width:370px; margin-left:3px">Name FIVE<br /><i style="font-weight:normal;margin-left: 20px"></i></span></span></span><br /><br /><br />
Code: Select all
function Initialize()
measureSite = SKIN:GetMeasure('MeasureSite')
end
function Update()
msSite = measureSite:GetStringValue()
if msSite == '' then return end
dummyString, dataCount = string.gsub(msSite, '<span class="Others".->', '')
print(dataCount)
end