It is currently March 28th, 2024, 6:08 pm

WebParser Relative Pathing Problem

Get help with creating, editing & fixing problems with skins
Post Reply
LostMyPassport
Posts: 4
Joined: September 18th, 2017, 5:32 am

WebParser Relative Pathing Problem

Post by LostMyPassport »

Hi all,

Im writing a little quote-fetcher to interface with poems.com.

Currently, I have somehow managed to throw my two webparser measures into an infinite loop...though I don't know how xD

Basically, the first webparser goes to the home page, finds the poem-of-the-day weblink, and passes that url to the second webparser. The second webparser uses that relative path (appended to the home domain) to grab the text of the poem and the author.

Where did I go wrong?

Code: Select all

[Rainmeter]
Update=1000
UpdateDivision=3600
AccurateText=1
DynamicWindowSize=1

[Variables]
;for parsing the return values - not the prettiest solution, but it works
SUB="<p>":"","</p>":"","&nbsp;":" ","<i>":"","</i>":"","<br />":"",'<span id="header">':"",'<span id="poem">':"","</span>":"",'<div id="page_title">':"","</div>":""

[MeasurePoemLocation]
Measure=Plugin
Plugin=WebParser
UpdateRate=1800
Url=http://poems.com/
RegExp=(?siU)a href="poem.php?date=(.*)">
FinishAction=[!CommandMeasure MeasureSite "Update"] 

[MeasureSite]
Measure=Plugin
Plugin=WebParser
UpdateRate=1800
Url=http://poems.com/poem.php?date=[&MeasurePoemLocation]
RegExp=(?siU)<title>Poetry Daily: (.*)</title>.*<span id="poem">(.*)<span id="byline"
StringIndex=1
DynamicVariables=1

[MeasureTitle]
Measure=Plugin
Plugin=WebParser
Url=[MeasureSite]
StringIndex=1
Substitute=#SUB#

[MeasurePoem]
Measure=Plugin
Plugin=WebParser
Url=[MeasureSite]
StringIndex=2
Substitute=#SUB#

[MeterAuthor]
Meter=String
MeasureName=MeasureAuthor
FontSize=30

[MeterPoem]
y=15R
Meter=String
MeasureName=MeasurePoem
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: WebParser Relative Pathing Problem

Post by mak_kawa »

In RegExp in [MeasurePoemLocation], "?" is a special character. So an escape character is needed before it. And you missed "StringIndex=1". Perhaps, following code will work.

Code: Select all

[MeasurePoemLocation]
Measure=Plugin
Plugin=WebParser
UpdateRate=1800
Url=http://poems.com/
RegExp=(?siU)poem.php\?date=(.*)">
FinishAction=[!CommandMeasure MeasureSite "Update"]
StringIndex=1
LostMyPassport
Posts: 4
Joined: September 18th, 2017, 5:32 am

Re: WebParser Relative Pathing Problem

Post by LostMyPassport »

Ah, that did it. Thanks!
Post Reply