It is currently May 7th, 2024, 2:50 pm

WebParser measure not returning expected value!

Get help with creating, editing & fixing problems with skins
Havegum
Posts: 4
Joined: January 25th, 2013, 4:07 am

WebParser measure not returning expected value!

Post by Havegum »

Hello! I'm trying to make a skin that will show the last 5 threads of this forum, but I've encountered problems such as "Not enough substrings!" when using StringIndex=1; and the Meter not showing any value at all.

As for now, the MeterItem1 returns "Link: " with no value, and I don't get the "Not enough substrings!"-error

Relevant code:

Code: Select all

[Rainmeter]
Author=Havegum
Update=1000
DynamicWindowSize=1

[MeasurePage]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=1800
Download=1
DownloadFile="website.txt"
Url="http://www.newgrounds.com/bbs/forum/1"
RegEx=(Moved down for legibility)
; Should return StringIndex' up to 10
ErrorString="Whops!"

[MeasureChild1]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasurePage]
StringIndex=1
ErrorString="Whops!"

[MeterItem1]
Meter=String
MeasureName=MeasureChild1
Text="Link: %1"
My RegEx is:

Code: Select all

RegEx="(?siU)<tr class=".*</td>.*<a href="(.*)">(.*)</a>
.*<tr class=".*</td>.*<a href="(.*)">(.*)</a>.*<tr class=".*</td>.*<a href="(.*)">(.*)</a>
.*<tr class=".*</td>.*<a href="(.*)">(.*)</a>
.*<tr class=".*</td>.*<a href="(.*)">(.*)</a>
.*"
And according to RainRegExp, should return something like
1==> [Thread link]
2==> [Thread title]
...
10==> [Thread title]


Thank you in advance!
User avatar
moshi
Posts: 1740
Joined: November 13th, 2012, 9:53 pm

Re: WebParser measure not returning expected value!

Post by moshi »

the regular expression looks good. but it should be all in one line.

Code: Select all

RegEx="(?siU)<tr class=".*</td>.*<a href="(.*)">(.*)</a>.*<tr class=".*</td>.*<a href="(.*)">(.*)</a>.*<tr class=".*</td>.*<a href="(.*)">(.*)</a>.*<tr class=".*</td>.*<a href="(.*)">(.*)</a>.*<tr class=".*</td>.*<a href="(.*)">(.*)</a>.*"
if there are still problems, then try commenting that download part (it is unnecessary).

Code: Select all

;Download=1
;DownloadFile="website.txt"
Havegum
Posts: 4
Joined: January 25th, 2013, 4:07 am

Re: WebParser measure not returning expected value!

Post by Havegum »

The RegEx is one line in the .ini file. Don't know why it turned out that way in the forum.
I've tried with and without the download part, it still returns no value. However, when I turn off download I get the warning:
"WebParser.dll: [MeasureChild1] Not enough substrings!"

So there's some progress, I guess. Is there any reason looking for StringIndex=1 shouldn't work?
Perhaps I'm using (.*) wrong?
User avatar
MaroonED
Posts: 61
Joined: November 6th, 2011, 4:50 pm
Location: Germany

Re: WebParser measure not returning expected value!

Post by MaroonED »

Hi Havegum,

have you tried using RainRegExp for the debugging? I couldn't get any WebParser measure going without it. Here's a link to the appropriate post: http://rainmeter.net/forum/viewtopic.php?f=18&t=769.

MaroonED
Havegum
Posts: 4
Joined: January 25th, 2013, 4:07 am

Re: WebParser measure not returning expected value!

Post by Havegum »

RainRegExp shows the expected value.

Code: Select all

01==> /bbs/topic/1330779
02==> Best of 2012 Nominees
03==> /bbs/topic/1330940
...
09==> /bbs/topic/1324658
10==> What music are you listening to
(10 strings alternating between link and title)

This leads me to think I must've done something wrong when calling for the information in either the measure, or meter.

Code: Select all

[MeasureChild1]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasurePage]
StringIndex=1
I've tried with and without a set ErrorString, and the meter still shows nothing. Is the regEx somehow returning nothing as value without the ErrorString kicking in?

Code: Select all

[MeterItem1]
Meter=String
MeasureName=MeasureChild1
Text="Link: %1"
The meter shows "Link: " and replaces %1 with nothing. I find it hard to believe I messed something up in the meter because it seems so basic.

According to the thread about RainRegExp, someone else has been having problems with it not enough substrings, but in their case it at least returned for stringindex1 (at least that's what I gather).
User avatar
GhostMatrix
Rainmeter Sage
Posts: 141
Joined: April 18th, 2009, 8:26 pm
Location: Montreal, Quebec, Canada 45.5658°N, 73.5898°W UTC -5

Re: WebParser measure not returning expected value!

Post by GhostMatrix »

Hi Havegum!

First it's not RegEx= but RegExp=

Your using a general tag <tr class=".*</td>.*<a href="(.*)">(.*)</a> who is used everywhere on the page, You have to be more specific like this <tr class="bbs.*">.*<span>.*<a href="(.*)">(.*)</a>

Now for the link value you only have a part of it, you will have to add the missing part in the Variable section and use it in the Meter.

Example for 2 threads:

Code: Select all

[Rainmeter]
Author=Havegum
Update=1000
DynamicWindowSize=1

[Variables]
Link=http://www.newgrounds.com

[MeasurePage]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=1800
Url="http://www.newgrounds.com/bbs/forum/1"
RegExp="(?siU)<tr class="bbs.*">.*<span>.*<a href="(.*)">(.*)</a>.*<tr class="bbs.*">.*<span>.*<a href="(.*)">(.*)</a>"
; Should return StringIndex' up to 10
ErrorString="Whops!"

[MeasureChild1]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasurePage]
StringIndex=1
ErrorString="Whops!"

[MeasureChild2]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasurePage]
StringIndex=2
ErrorString="Whops!"

[MeasureChild3]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasurePage]
StringIndex=3
ErrorString="Whops!"

[MeasureChild4]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[MeasurePage]
StringIndex=4
ErrorString="Whops!"

[MeterItem1]
Meter=String
MeasureName=MeasureChild1
X=0
Y=0
Text="Link: #Link#%1"
LeftMouseDownAction=#Link#[MeasureChild1]

[MeterItem2]
Meter=String
MeasureName=MeasureChild2
X=0
Y=15
Text="Topic: %1"

[MeterItem3]
Meter=String
MeasureName=MeasureChild3
X=0
Y=30
Text="Link: #Link#%1"
LeftMouseDownAction=#Link#[MeasureChild3]

[MeterItem4]
Meter=String
MeasureName=MeasureChild4
X=0
Y=45
Text="Topic: %1"
GM
If at first you don't succeed; call it version 0.1

Image
Havegum
Posts: 4
Joined: January 25th, 2013, 4:07 am

Re: WebParser measure not returning expected value!

Post by Havegum »

Derp, after I got the extra "p" in RegEx, everything worked like a charm! Thank you GhostMatrix for the elaborate help! Here's what it looks like:

Image