It is currently March 29th, 2024, 1:59 am

[Solved] WebParser Error

Get help with creating, editing & fixing problems with skins
User avatar
Seahorse
Posts: 1175
Joined: June 9th, 2010, 5:56 pm
Location: Locks heath, UK

[Solved] WebParser Error

Post by Seahorse »

I've launched debug & get this error:

Code: Select all

DEBUG: (00:01:01.058) WebParser: [MeasureGamesPlayed] Matching error! (-1)
I presume this means I'm getting something wrong.

If I read it right I need 4 things for RegExp enclosed in speechmarks:
  • (?siU)
    the HTML BEFORE the bit I want
    (.*)
    The HTML after as a STOP.
This is the section of the site I am interrogating:
<td class=""> Games Played: </td>

<td class="td-number"> 2&nbsp;265 </td>
</tr>

<tr>
<td class=""> Victories: </td>
<td class="td-number"> 1&nbsp;252 (55%) </td>

</tr>

<tr>
<td class=""> Defeats: </td>
<td class="td-number"> 953 (42%) </td>
</tr>

<tr>
<td class=""> Battles Survived: </td>

<td class="td-number"> 894 (39%) </td>
</tr>
And this is the code I'm trying to use (and failing). I've been cross examining the documents and the tutorial with no success.

Code: Select all

[MeasureGamesPlayed]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=1800
Url=#WoTURL#
RegExp="(?siU)<td class=""> Games Played: </td> <td class="td-number">(.*)</td>"
StringIndex=1
DecodeCharacterReference=1

[MeterGamesPlayed]
MeasureName=MeasureGamesPlayed
Meter=STRING
X=2
Y=2
FontColor=255,255,255,255
FontSize=12
StringAlign=LEFT
Prefix="Games Played: "
i.e StringIndex1 output should read "Games Played: 2,265".

I have tried this with and without the carriage returns in the webpage code and would appreciate a steer.

This works fine, from the same page:

Code: Select all

[MeasurePlayerName]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=1800
Url=#WoTURL#
RegExp="(?siU)<title>WoT: Player Profile:(.*)</title>"
StringIndex=1
DecodeCharacterReference=1
Last edited by Seahorse on June 26th, 2011, 10:33 am, edited 2 times in total.
"Regrettably your planet is one of those scheduled for demolition"
Mike

My Skins at DeviantArt

User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: WebParser Error

Post by jsmorley »

RegExp="(?siU)Games Played:.*td-number"> (.*) </td>.*Victories:.*td-number"> (.*) </td>"

That will work. You will want to Substitute= the encoded non-breaking space for a comma I guess.
6-25-2011 6-22-02 PM.jpg
The thing you didn't mention above in your perfectly correct description of a RegExp is that .* (without the parentheses as in a "capture") means "skip everything until the next thing I specifically test for". That is an important tool in zeroing in on what you want without having to deal with every special character like carriage return or huge expanses of spaces.

(.*) = Capture everything from here til the next thing I specifically test for
.* = Skip everything from here til the next thing I specifically test for
You do not have the required permissions to view the files attached to this post.
User avatar
Seahorse
Posts: 1175
Joined: June 9th, 2010, 5:56 pm
Location: Locks heath, UK

Re: WebParser Error

Post by Seahorse »

OK, that works, I've removed:

DecodeCharacterReference=1

and added:

Substitute="&nbsp;":","

All good. This is just so it's clear in my head, plus I can look it up again later :D

So, Games Played:.*td-number"> (.*) </td> boils down to:

Find this Ignore stuff until This Save to String1 Stop recording

Therefore the example you gave contains StingIndex1 and String Index2 if I have this right, however I get the same output twice (2,265) using the following, I've commented out my line where Playername should be StringIndex1 and Games Played is SI2.

Code: Select all

[MeasureWotStats]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=1800
Url=#WoTURL#
;RegExp="(?siU)<title>WoT: Player Profile:(.*)</title>.*Games Played:.*td-number"> (.*) 

</td>.*Victories:.*td-number"> (.*) </td>"
RegExp="(?siU)Games Played:.*td-number"> (.*) </td>.*Victories:.*td-number"> (.*) </td>"
StringIndex=1
Substitute="&nbsp;":","

[MeasureGamesPlayed]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=#WoTURL#
StringIndex=2

[MeterPlayerName]
MeasureName=MeasureWoTStats
Meter=STRING
X=10
Y=0
FontColor=255,255,255,255
FontSize=12
StringAlign=LEFT
Prefix="Character: "

[MeterGamesPlayed]
MeasureName=MeasureWoTStats
Meter=STRING
X=r
Y=14
FontColor=255,255,255,255
FontSize=12
StringAlign=LEFT
Prefix="Games Played: "
Clearly I'm doing something wrong, but not sure what. I'm just going to add them one at a time to save problems, however, going past 1 is proving difficult... :o
"Regrettably your planet is one of those scheduled for demolition"
Mike

My Skins at DeviantArt

User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: WebParser Error

Post by jsmorley »

1) So, Games Played:.*td-number"> (.*) </td> boils down to:

Find this Ignore stuff until This Save to String1 Stop recording

Correct...

2) The only time you should have StringIndex=xx on the main WebParser measure (the one with the RegExp on it) is when there is ONLY one capture in that measure. Otherwise, you use the main measure to get all captures into StringIndexes, and use subsequent "child" measures to pick off the individual StringIndexes (captures) from that array created in the main measure.

So a measure with RegExp="(?siU)<title>(.*)</title>.*<body>(.*)</body>" will not have any StringIndex on it, or you will get both captures in the same StringIndex. Just leave StringIndex off.

Then two child WebParser measures, using that main one as the URL=[MeasureName] will have StringIndex=1 and StringIndex=2 to cause each to contain one of the captures that you can then use in calcs, meters, other measures, whatever.
User avatar
Seahorse
Posts: 1175
Joined: June 9th, 2010, 5:56 pm
Location: Locks heath, UK

Re: WebParser Error

Post by Seahorse »

Got it, now to add the rest, will do that in the morning as brain is frazzled. Thanks for the help.
"Regrettably your planet is one of those scheduled for demolition"
Mike

My Skins at DeviantArt

User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: WebParser Error

Post by jsmorley »

Seahorse wrote:Got it, now to add the rest, will do that in the morning as brain is frazzled. Thanks for the help.
My pleasure.
User avatar
Seahorse
Posts: 1175
Joined: June 9th, 2010, 5:56 pm
Location: Locks heath, UK

Re: [Solved] WebParser Error

Post by Seahorse »

Writing my own weather skin and having an issue with one part that is not playing, the icon "27" is present and works in the old skin, but Rainmeter's "About" shows no value being returned for String Index 3, although all the others before and after are fine.
Capture.PNG
I know I have to record them in the order that they appear and seeing as it is immediately after Current conditions in <t> it should be about as easy to add as possible.

I'm running the old skins and the new skin as variants, sharing the same image folder allowing me to toggle between them, old is OK, but I can't see a difference in them to explain the missing icon.

Page source:

Code: Select all

<head><locale>en_US</locale><form>MEDIUM</form><ut>C</ut><ud>km</ud><us>km/h</us><up>mb</up><ur>mm</ur></head><loc id="UKXX1630"><dnam>Locks Heath, United Kingdom</dnam><tm>10:11 PM</tm><lat>50.86</lat><lon>-1.28</lon><sunr>5:08 AM</sunr><suns>9:13 PM</suns><zone>1</zone></loc><cc><lsup>7/15/11 9:45 PM Local Time</lsup><obst>Solent Mrsc, UNITED KINGDOM</obst><tmp>16</tmp><flik>16</flik><t>Showers in the Vicinity</t><icon>27</icon><bar><r>1014.2</r><d>steady</d></bar><wind><s>23</s><gust>N/A</gust><d>230</d><t>SW</t></wind><hmid>90</hmid><vis>16.1</vis><uv><i>0</i><t>Low</t></uv><dewp>14</dewp><moon><icon>15</icon><t>Full</t></moon></cc><dayf><lsup>7/15/11 7:09 PM Local Time</lsup><day d="0" t="Friday" dt="Jul 15"><hi>N/A</hi><low>14</low>
Actual URL without the variables.

Measures:

Code: Select all

[MeasureWeather]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=1800
Url=http://xml.weather.com/weather/local/#Location#?cc=*&unit=#ImperialorMetric#&dayf=3
RegExp="(?siU)<head>.*<tmp>(.*)</tmp>.*<t>(.*)</t>.*<icon>(.*)</icon>.*<lsup>.*<hi>(.*)</hi>.*<low>(.*)</low>"[/spoiler]
The Meters are unchanged as I'm getting the RegExp (complete as it is) before fiddling.

As always, I'm sure I am doing something dumb, but seeing as everything around it works just fine... :???:
You do not have the required permissions to view the files attached to this post.
"Regrettably your planet is one of those scheduled for demolition"
Mike

My Skins at DeviantArt

User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [Solved] WebParser Error

Post by jsmorley »

Your RegExp works fine for me...
7-15-2011 5-50-55 PM.jpg
Sure you don't have some error or typo in the "child" measure that is returning the icon number?
You do not have the required permissions to view the files attached to this post.
User avatar
Seahorse
Posts: 1175
Joined: June 9th, 2010, 5:56 pm
Location: Locks heath, UK

Re: [Solved] WebParser Error

Post by Seahorse »

Argh - you are correct, time for bed I guess, brain frazzed... :?
"Regrettably your planet is one of those scheduled for demolition"
Mike

My Skins at DeviantArt