It is currently April 16th, 2024, 9:56 pm

Web Parser Primer help

Get help with creating, editing & fixing problems with skins
Dawson
Posts: 2
Joined: July 5th, 2010, 6:41 pm

Web Parser Primer help

Post by Dawson »

I have been following the web parser primer by Jeffrey Morley to make a stock exchange script. I have a working script but need a bit of help to finish it off.

here is what I have:

Code: Select all

;[BEGIN CONFIG FILE]==============================

[Rainmeter]
Update=1000

[Variables]
Symbol=csco
URL="http://uk.finance.yahoo.com/q?s=#Symbol#"
FontColor=255, 255, 255, 255
FontFace=rockwell
Substitute="&":"&",""":"","&Quot;":"","<br>":"","![CDATA[":"","]]":"","...":"","<":"",">":"","/PRE>":"","PRE>":"","<":""

;[WEBSITE MEASURES]===============================

[MeasureWebsite]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=1800
Url=#URL#
RegExp="(?siU)<h1>(.*)<span>(.*)</span>.*<span id="yfs_l10_#Symbol#">(.*)</span>.*<span id="yfs_t10_#Symbol#">(.*)</span>.*<img width="10" height="14" border="0" src="(.*)" alt="(.*)"> <b class="(.*)">(.*)</b>.*<span id="yfs_p20_#Symbol#" class="yfi_quote_price"><b class="(.*)">(.*)</b></span>.*<td class="yfnc_tabledata1">(.*)</td>.*<span id="yfs_g00_#Symbol#">(.*)</span>.*<span id="yfs_h00_#Symbol#">(.*)</span>"

[MeasureCompany]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureWebsite]
StringIndex=1

[MeasureCode]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureWebsite]
StringIndex=2

[MeasureLastTrade]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureWebsite]
StringIndex=3

[MeasureTradeTime]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureWebsite]
StringIndex=4

[MeasureChange]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureWebsite]
StringIndex=8

[MeasureChange%]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureWebsite]
StringIndex=10

[MeasurePrevClose]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureWebsite]
StringIndex=11

[MeasureTodaysLow]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureWebsite]
StringIndex=12

[MeasureTodaysHigh]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureWebsite]
StringIndex=13

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

[MeterBackground]
Meter=IMAGE
X=1
Y=1
H=220
W=300
SolidColor=0,0,0,255

[MeterCompany]
MeasureName=MeasureCompany
Meter=STRING
X=2
Y=2
FontColor=#FontColor#
FontSize=12
StringAlign=LEFT
FontFace=#FontFace#
Antialias=1

[MeterCode]
MeasureName=MeasureCode
Meter=STRING
X=200
Y=2
FontColor=#FontColor#
FontSize=12
StringAlign=LEFT
FontFace=#FontFace#
Antialias=1

[MeterLastTrade]
MeasureName=MeasureLastTrade
Meter=STRING
X=2
Y=17r
FontColor=#FontColor#
FontSize=12
StringAlign=LEFT
FontFace=#FontFace#
Antialias=1
Prefix="Last Trade: "

[MeterTradeTime]
MeasureName=MeasureTradeTime
Meter=STRING
X=2
Y=17r
FontColor=#FontColor#
FontSize=12
StringAlign=LEFT
FontFace=#FontFace#
Antialias=1
Prefix="Trade Time: "

[MeterChange]
MeasureName=MeasureChange
Meter=STRING
X=2
Y=17r
FontColor=#FontColor#
FontSize=12
StringAlign=LEFT
FontFace=#FontFace#
Antialias=1
Prefix="Change: "

[MeterChange%]
MeasureName=MeasureChange%
Meter=STRING
X=2
Y=17r
FontColor=#FontColor#
FontSize=12
StringAlign=LEFT
FontFace=#FontFace#
Antialias=1
Prefix="Change%: "

[MeterPrevClose]
MeasureName=MeasurePrevClose
Meter=STRING
X=2
Y=17r
FontColor=#FontColor#
FontSize=12
StringAlign=LEFT
FontFace=#FontFace#
Antialias=1
Prefix="Prev Close: "

[MeterTodaysLow]
MeasureName=MeasureTodaysLow
Meter=STRING
X=2
Y=17r
FontColor=#FontColor#
FontSize=12
StringAlign=LEFT
FontFace=#FontFace#
Antialias=1
Prefix="Todays Low: "

[MeterTodaysHigh]
MeasureName=MeasureTodaysHigh
Meter=STRING
X=2
Y=17r
FontColor=#FontColor#
FontSize=12
StringAlign=LEFT
FontFace=#FontFace#
Antialias=1
Prefix="Todays High: "
The problem is when I get to the change part, this value could either go up or go down which means the source code changes. I have worked around this to get the value but how do I determine if it has gone up or down and show the appropriate up.gif or down.gif

example source code if value goes up:

Code: Select all

<span id="yfs_c10_csco" class="yfi_quote_price"><img width="10" height="14" border="0" src="http://us.i1.yimg.com/us.yimg.com/i/us/fi/03rd/up_g.gif" alt="Up"> <b class="yfi-price-change-up">0.60</b></span> 
<span id="yfs_p20_csco" class="yfi_quote_price"><b class="yfi-price-change-up"> (0.19%)</b></span>
example source code if value goes down:

Code: Select all

<span id="yfs_c10_csco" class="yfi_quote_price"><img width="10" height="14" border="0" src="http://us.i1.yimg.com/us.yimg.com/i/us/fi/03rd/down_r.gif" alt="Down"> <b class="yfi-price-change-down">0.13</b></span>
<span id="yfs_p20_csco" class="yfi_quote_price"><b class="yfi-price-change-down"> (0.61%)</b></span>
User avatar
Chewtoy
Moderator
Posts: 995
Joined: June 10th, 2009, 12:44 pm
Location: Sweden

Re: Web Parser Primer help

Post by Chewtoy »

alt="Up">
alt="Down">
I'd measure those two. Substitute them for + and - if you want.
alt="(.*)">
I don't think, therefore I'm not.
Dawson
Posts: 2
Joined: July 5th, 2010, 6:41 pm

Re: Web Parser Primer help

Post by Dawson »

Thanks that works :) Now I will move onto adding images