It is currently April 26th, 2024, 7:33 am

Substitution Term for "

Get help with creating, editing & fixing problems with skins
MatteoFlash
Posts: 23
Joined: June 26th, 2010, 8:11 am

Re: Substitution Term for "

Post by MatteoFlash »

But what does it happen if there are entries like this?

Text1
Text2
Text3

If i use:

Code: Select all

RegExp="<font color.*>(.*)</font>.*<font color.*>(.*)</font>.*<font color.*>(.*)</font>"
in Text1 there is just one color to find.. Every "Text" are divided from <div> tag, so I have to put <div> and </div> on every RegExp. But if Text1 has 1 color, I think that this RegExp will give me an error, not showing any results from the search.. The problem is also that there are no limits to quantity of possible colors on every Text. I can have Text with a single color (white) and multiple (5/6 colors). If I set RegExp with the 6 possibilities, I suppose that the search will stop at Text1, because the code doesn't find anything after the first <font color.*>(.*)</font>

This should be the code (I'll try the same tonight):

Code: Select all

RegExp="<div>.*<font color.*>(.*)</font>.*<font color.*>(.*)</font>.*<font color.*>(.*)</font>.*</div>"
Do you think there won't be any errors about this situation? Thanks a lot for your suggestions
MatteoFlash
Posts: 23
Joined: June 26th, 2010, 8:11 am

Re: Substitution Term for "

Post by MatteoFlash »

I tried to put something like this in the code:

Code: Select all

<font color=.*>(.*)</font><font color=.*>(.*)</font></div>
This is the code which I can use if the webpage show Texts with two colors (and it works). But if a Text has just 1 color, the Skin doesn't show anything, because it can't find the second tag "<font color=.*>".
So if I put this, it cannot work with my needs.. While if I put just one color script, I'll have many quotation marks, at least I can put some substitutions like the following to remove the exadecimals color codes:

Code: Select all

"#000000":"","#FFFFFF":""
User avatar
Chewtoy
Moderator
Posts: 995
Joined: June 10th, 2009, 12:44 pm
Location: Sweden

Re: Substitution Term for "

Post by Chewtoy »

It seems to me as this could be solvable with the use of Optional-RegExps.
What it is really is, check if it exist, if it does - include it. If not - Don't give a rats about it.
http://www.regular-expressions.info/optional.html

So, it might be something like: <font color=.*>(.*)</font>(<font color=.*>(.*)</font>)?</div>
I don't think, therefore I'm not.
MatteoFlash
Posts: 23
Joined: June 26th, 2010, 8:11 am

Re: Substitution Term for "

Post by MatteoFlash »

This is an interesting thing.. The problem is that I have cumulated all the informations, so, if the second color exist, the "StringIndex"s will change for every info to extract. I hope to let you know by this:

Code: Select all

[Variables]
URL="..."
PLAYER1=<div id="handle"><font color="#FFFFFF">(.*)</font></div>
PLAYER2=<div id="handle"><font color="#FFFFFF">(.*)</font></div>
PLAYER3=<div id="handle"><font color="#FFFFFF">(.*)</font></div>
PLAYER4=<div id="handle"><font color="#FFFFFF">(.*)</font></div>

[Infos]
Measure=Plugin 
Plugin=Plugins\WebParser.dll 
UpdateRate=3 
Url=#URL# 
RegExp="(?siU)<TITLE>(.*)</TITLE>#PLAYER1##PLAYER2##PLAYER3##PLAYER4#"

[Player1]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[Infos]
StringIndex=4

[Player2]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[Infos]
StringIndex=5

[Player3]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[Infos]
StringIndex=6

[Player4]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[Infos]
StringIndex=7
If I add:

Code: Select all

(<font color=.*>(.*)</font>)?
then "StringIndex"s will change.. My will is to extract the whole information about every Player, maybe now I have to find a way to memoryze it into the same index, in order to have "dynamyc" exctraction
User avatar
Chewtoy
Moderator
Posts: 995
Joined: June 10th, 2009, 12:44 pm
Location: Sweden

Re: Substitution Term for "

Post by Chewtoy »

Use several measures instead of bunching them all together?
I assume they show different things, otherwise it would be pointless to have them I guess.
Anyway. If you just measure one player in one perser-measure, you can easily make it work.

Code: Select all

[Variables]
Player=.*<font color=.*>(.*)</font>(<font color=.*>(.*)</font>)?</div>

[Info1]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=3
Url=#URL#
RegExp="(?siU)<TITLE>(.*)</TITLE>#Player#

[Player1.1]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[Info1]
StringIndex=2

[Player1.2]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[Info1]
StringIndex=3

[Display]
Meter=String
MeasureName=Player1.1
MeasureName2=Player1.2
MeterStyle=DisplayText
Text=%1%2
Now, if the second fontcolour doesn't exist, that string will just be empty, and it won't effect what is displayed.
Then just make the same thing with the other players in different measures and meters.
I don't think, therefore I'm not.
MatteoFlash
Posts: 23
Joined: June 26th, 2010, 8:11 am

Re: Substitution Term for "

Post by MatteoFlash »

I didn't think about the two MeasureName linked on the display part, wonderful idea!

Btw, I have to extract data of first 4 players in a ranking. In the HTML code, they are in a sequential order, that's because I thought about searchin in a unique [Infos] tag.. Am I wrong?

Actually, I have other problems, this is the actual code:

Code: Select all

[Variables]
PLAYER=<div id="handle"><font.*>(.*)</font>(<font.*>(.*)</font>)?(<font.*>(.*)</font>)?(<font.*>(.*)</font>)?</div>

[Infos]
Measure=Plugin 
Plugin=Plugins\WebParser.dll 
UpdateRate=3 
Url=#URL# 
RegExp="(?siU)<TITLE>(.*)</TITLE>#PLAYER##PLAYER##PLAYER##PLAYER#"

[Player1.1]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[Infos]
StringIndex=4

[Player1.2]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[Infos]
StringIndex=6

[Player1.3]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[Infos]
StringIndex=8

[Player1.4]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[Infos]
StringIndex=10

[Player1Text]
MeasureName=Player1.1
MeasureName2=Player1.2
MeasureName3=Player1.3
MeasureName4=Player1.4
Meter=String
Text="%1%2%3%4"
The same thing for every 4 players.

Let's assume a source like this:

Code: Select all

<div id="handle"><font color="#FFFFFF"></font><font color="#000000">-</font><font color="#FFFFFF">Text1</font><font color="#0000FF">-</font></div>
In the log file, I obtain (at a particular row):

Code: Select all

DEBUG: (08:58:02.363) WebParser: (Index 17) 
DEBUG: (08:58:02.363) WebParser: (Index 18) <font color="#000000">-</font><font color="#FFFFFF">Text1</font><font color="#0000FF">-</font>
DEBUG: (08:58:02.363) WebParser: (Index 19) -</font><font color="#FFFFFF">Text1</font><font color="#0000FF">-
and next lines are about the next player. I'm not able to capture entire "-Text1-" without all those colours tags. Maybe (surely) I'm wrong about something

Thanks really a lot for the support
User avatar
Chewtoy
Moderator
Posts: 995
Joined: June 10th, 2009, 12:44 pm
Location: Sweden

Re: Substitution Term for "

Post by Chewtoy »

This is becoming messy to read and understand... Could you post the text that you are trying to parse (don't exclude anything)?
I don't think, therefore I'm not.
MatteoFlash
Posts: 23
Joined: June 26th, 2010, 8:11 am

Re: Substitution Term for "

Post by MatteoFlash »

Of course.
<title>Test</title>
<body>
<div id="ping">48ms</div><div id="frags">181</div><div id="handle"><font color="#FFFFFF"></font><font color="">co</font></div><br />
<div id="ping">48ms</div><div id="frags">120</div><div id="handle"><font color="#FFFFFF"></font><font color="#00FFFF">-</font><font color="#828282">ini</font><font color="#00FFFF">-</font></div><br />
<div id="ping">62ms</div><div id="frags">108</div><div id="handle"><font color="#FFFFFF"></font><font color="#0000FF">A</font><font color="#FF0000">F</font><font color="#FFFF00">O</font><font color="#FFFFFF"></font><font color="#00FF00">Wak</font><font color="#FFFFFF">kocfer</font></div><br />

<div id="ping">51ms</div><div id="frags">102</div><div id="handle"><font color="#FFFFFF">bil0r </font></div><br />
<div id="ping">80ms</div><div id="frags">91</div><div id="handle"><font color="#FFFFFF">j0jo</font></div><br />
<div id="ping">64ms</div><div id="frags">84</div><div id="handle"><font color="#FFFFFF">I4o</font></div><br />
<div id="ping">27ms</div><div id="frags">68</div><div id="handle"><font color="#FFFFFF"></font><font color="#FF0000">=&</font><font color="#00FF00">||</font><font color="#0000FF">|</font><font color="#00FF00">||</font><font color="#FF0000">&<=</font></div><br />

<div id="ping">192ms</div><div id="frags">67</div><div id="handle"><font color="#FFFFFF">r0ckybalboa</font></div><br />
<div id="ping">66ms</div><div id="frags">66</div><div id="handle"><font color="#FFFFFF">Patricio</font></div><br />
<div id="ping">23ms</div><div id="frags">33</div><div id="handle"><font color="#FFFFFF">el machete</font></div><br />
<div id="ping">200ms</div><div id="frags">21</div><div id="handle"><font color="#FFFFFF">PAMOGAMA</font></div><br />
<div id="ping">104ms</div><div id="frags">6</div><div id="handle"><font color="#FFFFFF"></font><font color="#00FF00">Dragon</font></div><br />

<div id="ping">64ms</div><div id="frags">0</div><div id="handle"><font color="#FFFFFF">UnnamedPlayer</font></div><br /></body>
In last posts, I didnt' write about "Ping" and "Frags" extraction just to avoid to get a mess into the code, but I think we can keep this not a part of the actual problem.
In conclusion, my will is to extract "Ping", "Frags" and "Name" from this list of values (ex: 48ms | 181 | co , 48ms | 120 | -ini- , ..)

EDIT: I'm using this exact code in a Text File in my computer, it's an exctraction from the original webpage, to have a cleaned version of the source (to work on)
poiru
Developer
Posts: 2872
Joined: April 17th, 2009, 12:18 pm

Re: Substitution Term for "

Post by poiru »

MatteoFlash wrote:So, by now, I have to surrender about the idea to substitute quotation marks, is this right?
#QUOT# can be used in Substitute= starting from Rainmeter 1.3 r510 (not available for public as of writing this post) :)
MatteoFlash
Posts: 23
Joined: June 26th, 2010, 8:11 am

Re: Substitution Term for "

Post by MatteoFlash »

Thanks for this notification! I'll try the #QUOT# code as soon as I'll be able to download the r510 beta :D