It is currently April 19th, 2024, 3:21 am

WebParser 99 Capture Limit Fix Section PHP-Generator

Share and get help with Plugins and Addons
xorc
Posts: 1
Joined: August 8th, 2013, 2:21 pm

WebParser 99 Capture Limit Fix Section PHP-Generator

Post by xorc »

(Please help with the title. :-))

A little proof of concept PHP generator script
to bypass the 99 StringIndex limitation of Rainmeters WebParser.dll
Because it's a pain in the ass to copy paste these things.
Which I used to make a little widget for a friend of mine. And thought it was worth sharing, as I did not find much on the topic.

Generated working result can be found on:
http://pastebin.com/bsV1S5Sq


It can be run/used in http://phpfiddle.org/

This particular example is a working "skin"/ini/whatever you'd call it
to retrieve the latest mangafox.me manga results (66 ones).
  • The first WebParser does the first 33 items (with 3 captures, title/link/date)
    The second WebParser skips/steps the first 33, and retrieves the 33 after it.
33(items)*3(captures)==99 Limit

Have fun, it's totally free to use (or not use, depending how useful this would be)
Thanks too jsmorley for making My life easier with his RainRegExp.


These are the regex variables residing in [Variables] section.
To be used within the Regexp within your Measure section.
[rename them to your likings. If you decide to change the ITEM and STEP variable; it should be done consistantly across the script. and the rainmeter sections defined in strings.]

#ITEM# is the capture regex
#STEP# is the same regex as ITEM without the capture's. This is needed to continue where
the first WebParser instance breaks on the 99 capture limit.




The requirements in the actual skin/ini/whatever

Code: Select all

[Variables]
ITEM=.*<dt>.*<em>(.*)</em>.*<span class="chapter nowrap">.*<a href="(.*)" class="chapter">(.*)</a> .*</span></dt>.*
STEP=.*<dt>.*<em>.*</em>.*<span class="chapter nowrap">.*<a href=".*" class="chapter">.*</a> .*</span></dt>.*
The actual generator script is below.

Code: Select all

<?php
$parser = '

[MeasureMangaFoxParser%1$d]
Measure=Plugin
Plugin=WebParser
URL=http://mangafox.me/releases/
RegExp="(?siU).*<ul id="updates">.*%2$s.*</ul>.*"

';
$string = '
;=========[ %1$d ]===================;

[MeasureDate%1$d]
Measure=Plugin
Plugin=WebParser
URL=[MeasureMangaFoxParser%2$d]
StringIndex=%3$d

[MeasureURL%1$d]
Measure=Plugin
Plugin=WebParser
URL=[MeasureMangaFoxParser%2$d]
StringIndex=%4$d

[MeasureTitle%1$d]
Measure=Plugin
Plugin=WebParser
URL=[MeasureMangaFoxParser%2$d]
StringIndex=%5$d

;*******[Style]********************;

[MeterTitle%1$d]
Meter=String
MeterStyle=styleLeftText
MeasureName=MeasureTitle%1$d
LeftMouseUpAction=["[MeasureURL%1$d]"]
DynamicVariables=1
ClipString=2
Y=14r
; 14 pixels below the first title (R = Relative, Relative to the previous)
X=12
ClipStringW=180
H=14

	
[MeterDate%1$d]
Meter=String
MeasureName=MeasureDate%1$d
MeterStyle=styleRightText
DynamicVariables=1
X=230
Y=0r


';

# This statement allows you to have a copy pastable result on http://phpfiddle.org/
echo '<pre>';
function generate ($amount , $parser, $string, $step_amount = 0, $parseridx = 1) {
	
	$offset = 0;
	print htmlentities(sprintf ($parser , $parseridx, str_repeat ("#STEP#" , $step_amount) . str_repeat ("#ITEM#" , $amount)));
	for ($i = 1; $i <= $amount; $i++) {
		
		printf ($string , $i+$step_amount , $parseridx, ++$offset, ++$offset, ++$offset);
	}
}

# This generates one parser section, and multiplies the actual Measures and corresponding Styles.
# First argument is the amount of items you'd want to generate (Mind you're captures. 33*3 = 99 = WebParser Limit
# Second argument is the parser section which will be used for in this case 33 items
# Third argument is the actual Measure & Style's defined above.
generate (33 , $parser , $string);

# First argument is the amount of items you'd want to generate (Mind you're captures. 33*3 = 99 = WebParser Limit
# Second argument is the parser section which will be used for in this case the second 33 items
# Third argument is the actual Measure & Style's defined above.
# Fourth argument denotes to skip 33 items, previously done by the previous generate command
# Fifth argument denotes the Parser Identifier, this has to be incremented for each additional list
generate (33 , $parser , $string, 33 , 2);
?>