edit: Noticed I had RegExp= "(siU)...." instead of RegExp= "(?siU)..." but I haven't resolved the existing issue, yet.
It is currently April 28th, 2024, 11:35 am
RegExp/ WebPasrser- Is this accurate?
-
- Posts: 9
- Joined: December 29th, 2012, 8:19 pm
RegExp/ WebPasrser- Is this accurate?
I'm planning on making a little skin that will essentially read some stats from a website
I am working to understand how to use the web parser and regexp. As a start, I have attempted to obtain the total battles participated and display it.
At this point I know it is not working right, which means my understanding is definitely wrong. I also suspect that there may be a much more simplified way to get the information I am trying to find. Thoughts or guidance appreciated.
edit: Noticed I had RegExp= "(siU)...." instead of RegExp= "(?siU)..." but I haven't resolved the existing issue, yet.
edit: Noticed I had RegExp= "(siU)...." instead of RegExp= "(?siU)..." but I haven't resolved the existing issue, yet.
-
- Rainmeter Sage
- Posts: 5407
- Joined: April 12th, 2012, 9:40 pm
- Location: Cedar Point, Ohio, USA
Re: RegExp/ WebPasrser- Is this accurate?
Code: Select all
[RainMeter]
Update=1000
DynamicWindowSize=1
BackgroundMode=2
SolidColor=0,0,0,255
[mParent]
Measure=Plugin
Plugin=WebParser
URL="http://worldoftanks.com/community/accounts/1000518504-SysMunky/"
RegExp="(?siU)<td><span>Battles Participated</span></td>.*<td class="right value">(.*)</td>.*"
StringIndex=1
[mBattlePartic]
Measure=Plugin
Plugin=WebParser
URL=[mParent]
StringIndex=1
[MeterBatPartLbl]
Meter=String
MeasureName=mBattlePartic
FontSize=10
FontColor=222,255,227,255
X=10
Y=10
W=80
H=25
Text=Battles: %1
Changed the RegExp=...
Added the measurename to the first String meter and removed the second unneeded meter
The text "Battles Participated" occurs 4 times in the source code...
the 2nd occurrence seems the simplest to parse.
We look for the unique section <td><span>Battles Participated</span></td> then tell the parser to copy nothing .* until it
sees <td class="right value"> then copy everything (.*) up to the </td> then copy nothing .*
This returns the number of battles.
I would suggest using RainRegExp.exe tool developed by JSMorley to help you parse webpages... it's a great learning tool!
:: My DA Gallery :: Rainmeter DA Gallery :: Rainmeter Workshops :: Rainmeter Documentation :: BBCode Guide ::
-
- Posts: 9
- Joined: December 29th, 2012, 8:19 pm
Re: RegExp/ WebPasrser- Is this accurate?
Thank you! Your explanation made a lot more sense than a lot of what I had been able to find in my searches (and confusing attempts at understanding all the documentation). I was able to successfully create a rather sloppy working version after a ridiculous amount of trial and error, albeit a very sloppy, ugly, and poorly styled skin that i actually fear to return to finish. Given better understanding now, perhaps I wil start fresh and see if I can make something halfway pleasant.
One thing that I am puzzled by is that when i was looking at the source for the site, I see <td-class-number-nowidth">whereas you have <td class="right value"> Do you by chance know why these would be different?
Thanks again!
One thing that I am puzzled by is that when i was looking at the source for the site, I see <td-class-number-nowidth">whereas you have <td class="right value"> Do you by chance know why these would be different?
Thanks again!
-
- Rainmeter Sage
- Posts: 5407
- Joined: April 12th, 2012, 9:40 pm
- Location: Cedar Point, Ohio, USA
Re: RegExp/ WebPasrser- Is this accurate?
It depends on which of the 4 occurrences of "Battles Participated" you want to parse. The first 2 occurrences both give the number of battles. The difference is you used the first occurrence while I chose to parse the second to get the number of battles...SysMunky wrote:Thank you! Your explanation made a lot more sense than a lot of what I had been able to find in my searches (and confusing attempts at understanding all the documentation). I was able to successfully create a rather sloppy working version after a ridiculous amount of trial and error, albeit a very sloppy, ugly, and poorly styled skin that i actually fear to return to finish. Given better understanding now, perhaps I wil start fresh and see if I can make something halfway pleasant.
One thing that I am puzzled by is that when i was looking at the source for the site, I see <td-class-number-nowidth">whereas you have <td class="right value"> Do you by chance know why these would be different?
Thanks again!
The first occurrence has the prefix you give, the 2nd occurrence has a different prefix code; the one I used.
:: My DA Gallery :: Rainmeter DA Gallery :: Rainmeter Workshops :: Rainmeter Documentation :: BBCode Guide ::
-
- Posts: 127
- Joined: September 12th, 2012, 10:49 pm
Re: RegExp/ WebPasrser- Is this accurate?
Check out this extremely useful tool by JSMorley called RainRegExp. It lets you test the website and RegExp values that you're trying to parse. It helped me a lot because I didn't know a thing about RegExp, but now I feel more confident in getting my own codes, rather than using existing ones from skins like Gnometer, Illustro, etc.