It is currently April 27th, 2024, 10:56 pm

WebParser problem (Simple)

Get help with installing and using Rainmeter.
xMilowx
Posts: 1
Joined: May 31st, 2012, 4:21 pm

WebParser problem (Simple)

Post by xMilowx »

Why my code dont work? :(

Code: Select all

[Rainmeter]
Author=Milow
BackgroundMode=2

[MeasureWebtext]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=45000
Url="http://www.housetime.fm/tracklist/"
RegExp="(?siU).*<div style="width:345px;float:left; margin-top:11px; overflow:hidden">(.*)</div>.*"
StringIndex=1

[MeterSong]
MeasureName=MeasureWebtext
Meter=String
FontSize=12
FontColor=#FFFFFF
FontFace=Tahoma
Antialias=1
Prefix="Aktueller Song: "
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: WebParser problem (Simple)

Post by jsmorley »

You have two problems.

1) You need to add DynamicWindowSize=1 to the [Rainmeter] section of your skin, so the meter grows to fit the retrieved data properly.

2) Your RegExp is going to return the correct value, except that it will also return the linefeeds and spaces on either side of the value. You need to alter it to RegExp="(?siU).*<div style="width:345px;float:left; margin-top:11px; overflow:hidden">.*(\w.*)\W</div>". What this will do is: after hidden"> it will skip everything .* until a "word" char \w that is a-Z|0-9 is hit. Then it will capture everything until a non "word" char \W is hit (the linefeed at the end of the value).

That way you end up with:

Code: Select all

01=> Unknown Artist - Unknown Title
Instead of:

Code: Select all

01=> 
                            Unknown Artist - Unknown Title
User avatar
KreAch3R
Posts: 608
Joined: February 7th, 2011, 7:27 pm
Location: Thessaloniki, GR

Re: WebParser problem (Simple)

Post by KreAch3R »

I was playing around with your RegExp, but jsmorley already covered all problems. I went for another RegExp, though, because in my trials the provided RegExp was parsing things it shouldn't;
Here it is:

Code: Select all

(?siU).*<a href="/release/.*" style="color: #FFFFFF">(.*)</a>
P.S. For any other beginner user that may come to this page trying to figure out how to parse lines in Webparser, I will link this awesome post here.
Inactive, due to life changes. Send me a PM for any question.

Desktop DeviartArt
Image
malcolmn
Posts: 12
Joined: June 10th, 2012, 12:08 pm

Re: WebParser problem (Simple)

Post by malcolmn »

I have a similar problem and have tried this suggestion but still no go. Any Ideas ?

Code: Select all

[Rainmeter]
Author=Malcolm Newton
Update=1000
BackgroundMode=1

[Variables]
skin.Style=Horizontal
@Include=#SKINSPATH#\Variables.inc
skin.Width=600
Fpath=#CURRENTPATH#downloadfile\html.txt
Url=http://www.buffalogasprices.com/
RegExp=(?siU).*Buffalo Avg</h1>  <br />                  <h2>(.*)</h2>

; MEASURES ====================================

[LoadBuff]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=1200
Url=#UrL#
RegExp=#RegExp#
Debug2File="Debug2File.txt"
debug=2

;[DISPLAY METERS]==================================

[Line]
Meter=IMAGE
MeterStyle=sTextL

[Icon]
Meter=IMAGE
MeterStyle=sIcon
ImageName=gas.jpg

[Title]
Meter=STRING
MeterStyle=sTitle
Text=Gas Price in Buffalo NY
x=20

[Price3]
MeasureName=LoadBuff
Meter=STRING
X=2
y=22r
StringIndex=1
DynamicVariables=1
text=Buff :%1
debug log is

NOTICE: (02:17:45.281) Refreshing skin "waittimes\Gasprices-buff.ini"
DEBUG: (02:17:45.281) Reading file: C:\Documents and Settings\mnewton\Application Data\Rainmeter\Rainmeter.ini
DEBUG: (02:17:45.281) Reading file: C:\Documents and Settings\mnewton\My Documents\Rainmeter\Skins\waittimes\Gasprices-buff.ini
DEBUG: (02:17:45.281) Reading file: C:\Documents and Settings\mnewton\My Documents\Rainmeter\Skins\\Variables.inc
DEBUG: (02:17:45.281) C:\Documents and Settings\mnewton\My Documents\Rainmeter\Skins\waittimes\Debug2File.txt
DEBUG: (02:17:45.281) WebParser.dll: Fetching: http://www.buffalogasprices.com/
DEBUG: (02:17:45.781) WebParser.dll: [LoadBuff] (Index 0)





<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head>

<base id="ctl00_head_base" href="http://www.buffalogasprices.com/"></base
DEBUG: (02:17:45.781) WebParser.dll: [LoadBuff] (Index 1) 3.809


So it finds the right data 3.809 which is between a <h2> and an </h2)
but the text=Buff :%1
displays nothing

strange
I have another skin similar that works ok.
MN
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: WebParser problem (Simple)

Post by jsmorley »

malcolmn wrote:I have a similar problem and have tried this suggestion but still no go. Any Ideas ?
[LoadBuff]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=1200
Url=#UrL#
RegExp=#RegExp#
Debug2File="Debug2File.txt"
debug=2
StringIndex=1
malcolmn
Posts: 12
Joined: June 10th, 2012, 12:08 pm

Re: WebParser problem (Simple)

Post by malcolmn »

Great thanks
malcolmn
Posts: 12
Joined: June 10th, 2012, 12:08 pm

Re: WebParser problem (Simple)

Post by malcolmn »

Dual webparsers
second meter does not show %1

Code: Select all

[Rainmeter]
Author=Malcolm Newton
Update=1000
BackgroundMode=1


[Variables]
skin.Style=Horizontal
@Include=#SKINSPATH#\Variables.inc
skin.Width=#width.Notes#
Fpath=#CURRENTPATH#downloadfile\html.txt
Url1=http://tomorrowsgaspricetoday.com/ancaster-gas-prices.html?city=336
RegExp1=(?siU).*litre_pro_01" style="font-size:45px">(.*)</div>
Url2=http://www.buffalogasprices.com/
RegExp2=(?siU).*NewYorkState Average</h1><br />                <h2>(.*)</h2>

; MEASURES ====================================

[Loadfile]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=1200
Url=#UrL1#
RegExp=#RegExp1#
Debug=1

[LoadBuff]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=1200
Url=#UrL2#
RegExp=#RegExp2#
debug=1

[pr2]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[Loadfile]
StringIndex=1
Debug=1

[pr3]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[Loadbuff]
StringIndex=1
Debug=1

;[DISPLAY METERS]==================================

[Line]
Meter=IMAGE
MeterStyle=sTextL

[Icon]
Meter=IMAGE
MeterStyle=sIcon
ImageName=gas.jpg


[Title]
Meter=STRING
MeterStyle=sTitle
Text=Gas Price
x=20

[Price2]
MeasureName=pr2
Meter=STRING
X=2
y=22r
FontColor=0,0,0,255
FontSize=8
StringAlign=LEFT
FontFace=Tahoma
Antialias=1
text=Ancaster : %1

[Price3]
MeasureName=pr3
Meter=STRING
X=2
y=22r
FontColor=0,0,0,255
FontSize=8
StringAlign=LEFT
FontFace=Tahoma
Antialias=1
text=Buffalo   : %1
debug shows loadbuff index 1 is 3.743
loadfile index 1 is 122.1

first one shows the second does not. Any ideas?

debug below

Code: Select all

DEBUG: (12:27:23.750) Reading file: C:\Documents and Settings\mnewton\Application Data\Rainmeter\Rainmeter.ini
DEBUG: (12:27:23.750) Reading file: C:\Documents and Settings\mnewton\My Documents\Rainmeter\Skins\waittimes\Gasprices.ini
DEBUG: (12:27:23.750) Reading file: C:\Documents and Settings\mnewton\My Documents\Rainmeter\Skins\\Variables.inc
DEBUG: (12:27:23.765) WebParser.dll: Fetching: http://www.buffalogasprices.com/
DEBUG: (12:27:23.765) WebParser.dll: Fetching: http://tomorrowsgaspricetoday.com/ancaster-gas-prices.html?city=336
DEBUG: (12:27:24.187) WebParser.dll: [LoadBuff] (Index  0)





<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head>

<base id="ctl00_head_base" href="http://www.buffalogasprices.com/"></base
DEBUG: (12:27:24.187) WebParser.dll: [LoadBuff] (Index  1) 3.743
DEBUG: (12:27:24.344) WebParser.dll: [Loadfile] (Index  0) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>

	<me
DEBUG: (12:27:24.344) WebParser.dll: [Loadfile] (Index  1) 122.2
Last edited by Brian on June 12th, 2012, 1:37 pm, edited 1 time in total.
Reason: Please use [code] tags.
malcolmn
Posts: 12
Joined: June 10th, 2012, 12:08 pm

Re: WebParser problem (Simple)

Post by malcolmn »

Fixed it
cut out the 2 measures

Code: Select all

[pr2]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[Loadfile]
StringIndex=1
Debug=1

[pr3]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[Loadbuff]
StringIndex=1
Debug=1


added
StringIndex=1
to

Code: Select all

[Loadfile]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=1200
Url=#UrL1#
RegExp=#RegExp1#
StringIndex=1
Debug=1

and it works now
not sure why it didn't work with
previous code
Last edited by Brian on June 12th, 2012, 1:38 pm, edited 1 time in total.
Reason: [code] tags