It is currently May 2nd, 2024, 2:46 am

webparser regexp problems to pickup router Ip's

Get help with creating, editing & fixing problems with skins
malcolmn
Posts: 12
Joined: June 10th, 2012, 12:08 pm

webparser regexp problems to pickup router Ip's

Post by malcolmn »

I have another skin where I would like to get the 2 ip's
from my router (dual).
I have no problem with get the url login and webpage
back from the router the problem is to select the
2 ip's with Regex.
the page has crlf's and I get stuck trying to skip them.
I have tried \W \r etc but still get stuck.
i get the debug

Code: Select all

DEBUG: (07:02:19.219) WebParser.dll: [LoadIP] (Index  1)  


                0.0.0.0 
DEBUG: (07:02:19.219) WebParser.dll: [LoadIP] (Index  2) "---");


					else


                		document.write('216.208.38.122 
so its fairly close .
the code is
----------------------------------

Code: Select all

[Rainmeter]
Author=Malcolm Newton
Update=1000
BackgroundMode=1


[Variables]
skin.Style=Horizontal
@Include=#SKINSPATH#\Variables.inc
@Include2=#ROOTCONFIGPATH#SETTINGS\Style#skin.Style#.inc
skin.Width=#width.Notes#
Fpath=#CURRENTPATH#downloadfile\html.txt
;Url1=http://admin:admin@192.168.1.1
Url1=file://c:\temp\routers.txt
RegExp1=(?siU)<td width="32%">(\W.*)&nbsp.*<td width="32%">.*document.write\((\W.*)&nbsp


; MEASURES ====================================

[LoadIP]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=3600
Url=#UrL1#
RegExp=#RegExp1#
setindex=1
Debug=1



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

[Line]
Meter=IMAGE
MeterStyle=sTextL

[Icon]
Meter=IMAGE
MeterStyle=sIcon
ImageName=network.png


[Title]
Meter=STRING
MeterStyle=sTitle
Text=router ip's
x=30

[Price2]
MeasureName=loadIP
Meter=STRING
MeterStyle=sTextL
X=3
y=22r
NumOfDecimals=2
text=WAN IP1 : %1

[Price3]
MeasureName=loadIP
Meter=STRING
MeterStyle=sTextL
X=2
y=12r
NumOfDecimals=2
text=WAN IP2   : %2
-------------------------------------------
the file copy of the url is

Code: Select all

if (document.formsummary.dualwanEnabled.value=="0") document.write("WAN IP");

else document.write("WAN1 IP");

</script>

                </font></a></u></font><font color="#000000"> :</font> </td>

              <td width="32%"> 

                0.0.0.0 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 

              </td>

              <td width="27%"> 

                <input type=button value=Disconnect onClick=falseSubmit('12')> <input type=button value=Connect onClick=falseSubmit('13')>

              </td>

            </tr>

            <tr valign="middle"> 

              <td width="41%"><font color="#0000FF"><u><a href="network.htm"><font color="#000000"> 

                <script>

if (document.formsummary.dualwanEnabled.value=="0") document.write("DMZ IP");

else document.write("WAN2 IP");

</script>

                </font></a></u></font><font color="#000000"> :</font> </td>

              <td width="32%"> 

                <script> 

				    if ((document.formsummary.dualwanEnabled.value=="0") && (document.formsummary.DmzRangeFlag.value=="1"))

					    document.write("---");

					else

                		document.write('216.208.38.122 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ');			

				</script>

              </td>

              <td width="27%"> 

                 

              </td>

            </tr>
the non white space seems to hang up the regexp.
Any ideas would really help have spent quite a
few hours on this , found EditPad as a handy editor
with regexp search facility , helps a lot but still stuck.
User avatar
JamesAC
Developer
Posts: 318
Joined: July 14th, 2009, 5:57 pm

Re: webparser regexp problems to pickup router Ip's

Post by JamesAC »

If there is only ever 2 IP's in the page, then (?siU)(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b).*(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b) should work to just catch them. If there are more that you don't want to catch in some situations, then that will be slightly more complicated.
+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++
Quis custodiet ipsos custodes?
malcolmn
Posts: 12
Joined: June 10th, 2012, 12:08 pm

Re: webparser regexp problems to pickup router Ip's

Post by malcolmn »

Thanks James
now i get
DEBUG: (04:08:50.125) WebParser.dll: Fetching: file://c:\temp\routers.txt
DEBUG: (04:08:50.125) WebParser.dll: [LoadIP] (Index 0) 0.0.0.0 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</td>
<td width="27%">
<input type=button value=Disconnect onClick=falseSubmit('12')> <input type=button value=Connect onClick=falseSub
DEBUG: (04:08:50.125) WebParser.dll: [LoadIP] (Index 1) 0.0.0.0
DEBUG: (04:08:50.125) WebParser.dll: [LoadIP] (Index 2) 216.208.38.122
NOTICE: (04:08:50.125) Initialization successful
which is great,
but i cant get
index 1 or index 2 to show with

[Price2]
MeasureName=loadIP
Meter=STRING
MeterStyle=sTextL
X=3
y=22r
stringindex=1
text=WAN IP1 : %1

[Price3]
MeasureName=loadIP
Meter=STRING
MeterStyle=sTextL
X=2
y=12r
stringindex=2
text=WAN IP2 : %2
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: webparser regexp problems to pickup router Ip's

Post by jsmorley »

You don't use StringIndex on meters. The way it works is:

Code: Select all

[MeasureMain]
Measure=Plugin
Plugin=WebParser
Url=http://SomeSite.com
RegExp="(?siU)(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b).*(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b)"

[MeasureIPOne]
Measure=Plugin
Plugin=WebParser
Url=[MeasureMain]
StringIndex=1

[MeasureIPTwo]
Measure=Plugin
Plugin=WebParser
Url=[MeasureMain]
StringIndex=2

[MeterIPOne]
Meter=String
MeasureName=MeasureIPOne

[MeterIPTwo]
Meter=String
MeasureName=MeasureIPTwo
malcolmn
Posts: 12
Joined: June 10th, 2012, 12:08 pm

Re: webparser regexp problems to pickup router Ip's

Post by malcolmn »

great thanks