It is currently April 27th, 2024, 9:35 pm

Webparser help

Get help with creating, editing & fixing problems with skins
Fezz-ii-
Posts: 8
Joined: July 9th, 2010, 5:13 am

Webparser help

Post by Fezz-ii- »

I'm learning, slowly and painfully, how to work with the webparser plugin. I'm trying to make a script that displays a brotip that it pulled from the internet. I think everything should be good, except the RegExp line.. I don't know my perle.. Can anyone help me build that line?

Code: Select all

; ------------------------------------------------------------------------------------------------
; BROTIP READER

[Rainmeter]
Author=Zev.Isert@gmail.com
AppVersion=1
Update=40
MiddleMouseDownAction=!RainmeterRefresh #CURRENTCONFIG#
Backgroundmode=2

[TipFeed]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url="http://www.brotips.com/1068"
RegExp="(?siU).*<html>.*<body>.*<section id="main">.*<div>.*<h1>(.*)</h1>.*<p>(.*)</p>.*</div>.*</section id="main">.*</body>.*</html>"

[TipSource]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[TipFeed]
StringIndex=1
Substitute=" <br>":""

[TipText]
MeasureName=TipSource
Meter=String
X=7
Y=40
W=660
H=300
StringStyle=Normal
FontColor=255,255,255,255
FontSize=38
FontFace=Arial
AntiAlias=1
ClipString=1
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Webparser help

Post by jsmorley »

I'm not clear from your post what you are trying to return from the page, but the long and the short of it is that you want to search for text, using .* to "skip" areas of text you don't need, and using specific text to "get you to the part you want to capture".

What I would suggest is getting this tool: http://rainmeter.net/forum/viewtopic.php?p=5635#p5635, as it can really help with trying and debugging those RegExp= statements.

In any case, here is a little skin that will get those "Brotip" instructions from that page. Put the RegExp code into RainRegExp and you can get a sense of what it is doing, and then you can extend it as needed.

Code: Select all

[Rainmeter]
DynamicWindowSize=1
Update=1000

[MeasureParent]
Measure=Plugin
Plugin=WebParser
Url=http://www.brotips.com/1068
RegExp="(?siU)<section id="main".*<h1 unselectable="on">(.*)</h1>.*<p unselectable="on">(.*)<br>(.*)<br>(.*)<br>(.*)</p>"

[MeasureChild1]
Measure=Plugin
Plugin=WebParser
Url=[MeasureParent]
StringIndex=1

[MeasureChild2]
Measure=Plugin
Plugin=WebParser
Url=[MeasureParent]
StringIndex=2

[MeasureChild3]
Measure=Plugin
Plugin=WebParser
Url=[MeasureParent]
StringIndex=3

[MeasureChild4]
Measure=Plugin
Plugin=WebParser
Url=[MeasureParent]
StringIndex=4

[MeasureChild5]
Measure=Plugin
Plugin=WebParser
Url=[MeasureParent]
StringIndex=5

[MeterChild1]
Meter=String
MeasureName=MeasureChild1
Y=R
FontSize=12
FontColor=255,255,255,255

[MeterChild2]
Meter=String
MeasureName=MeasureChild2
Y=R
FontSize=12
FontColor=255,255,255,255

[MeterChild3]
Meter=String
MeasureName=MeasureChild3
Y=R
FontSize=12
FontColor=255,255,255,255

[MeterChild4]
Meter=String
MeasureName=MeasureChild4
Y=R
FontSize=12
FontColor=255,255,255,255

[MeterChild5]
Meter=String
MeasureName=MeasureChild5
Y=R
FontSize=12
FontColor=255,255,255,255