Page 1 of 1

WebParser Relative Pathing Problem

Posted: September 18th, 2017, 5:40 am
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

Re: WebParser Relative Pathing Problem

Posted: September 18th, 2017, 7:28 am
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

Re: WebParser Relative Pathing Problem

Posted: September 18th, 2017, 9:33 am
by LostMyPassport
Ah, that did it. Thanks!