It is currently April 24th, 2024, 11:33 pm

Help debugging RrgExp line with look ahead option

Get help with creating, editing & fixing problems with skins
User avatar
Codger
Posts: 97
Joined: May 29th, 2017, 3:16 pm

Help debugging RrgExp line with look ahead option

Post by Codger »

I'm using WebParser to scan a page for location and postal code.

The relevant part of the HTML looked like this

Code: Select all

<tr>
        <td>City</td>
        <td>
          <a class="flag flag-us" href="/countries/us"></a>
          Plano, Texas, United States
        </td>
      </tr>
    
      <tr>
        <td>Latitude/Longitude</td>
        <td data-loc="33.0198,-96.6989">33.0198,-96.6989</td>
      </tr>
    
      <tr>
        <td>Postal Code</td>
        <td>75026</td>
      </tr>
   
      <tr>
        <td>Route</td>
        <td><a href="/AS46562/192.238.232.0/22">192.238.232.0/22</a></td>
      </tr>
    
  </table>
After major hair pulling and learning my routine looked like this looked like this:

Code: Select all

[MeasureWebParseLocation]
Measure=Plugin
Plugin=WebParser
URL=#IPLocationSite#
RegExp=(?siU)City.*<a class="flag .*</a>\n(.*)</td>.*<td>Postal Code</td>.*<td>(.*)</td>
And this worked great. Except it appears parts of the US do not have zip codes, and yet have IPs. And this website, which I prefer for several reasons over the other choices I have found, omits the Postal Code line entirely rather than leave the field blank. So the HTML looks exactly like above with

Code: Select all

     <tr>
        <td>Postal Code</td>
        <td>75026</td>
      </tr>
missing. This of course causes my RegExp to fail and worse scramble WebParser to the point RM has to be rebooted to make it work again. So after yet more hair pulling and learning (or not) later I had this:

Code: Select all

[MeasureWebParseLocation]
Measure=Plugin
Plugin=WebParser
URL=#IPLocationSite#
RegExp=(?siU)City.*<a class="flag .*</a>\n(.*)</td>(?(?=.*<td>Postal Code</td>).*<td>(.*)</td>)
Which by my careful reading should return location and a blank for postal code but instead crashes.
And if there is a Postal Code it returns "Latitude/Longitude" in the Postal Code field. This should be a clue but is just pissing me off instead.

I've been at this all day and my eyes are crossing. Can someone spot what I am doing wrong?
[hr][/hr][hr][/hr]
"If you are the smartest one in the room, you are in the wrong room."
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help debugging RrgExp line with look ahead option

Post by balala »

For me the posted RegExp doesn't work, at all, neither the initial one, neither the edited one. But you're right, this is a classical example where the Lookahead Assertion should be used. If the webpage has the appropriate section (which contains the postal code), the following code will return through the [MeasurePostalCode] measure, this postal code. If that section is missing, the [MeasurePostalCode] measure will return an empty string:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1

[MeasureRainmeter]
Measure=Plugin
Plugin=WebParser
UpdateRate=-1
Url=file://c:\Users\Laci\Desktop\Proba.txt
;RegExp=(?siU)City.*<a class="flag .*</a>\n(.*)</td>.*<td>Postal Code</td>.*<td>(.*)</td>
RegExp=(?siU)<td>City</td>.*<a class=".*" href=".*"></a>(.*)</td>.*</tr>.*<tr>.*<td>Latitude/Longitude</td>.*<td data-loc=".*,.*">(.*),(.*)</td>.*</tr>.*(?(?=.*<tr>).*<td>Postal Code</td>.*<td>(.*)</td>.*</tr>).*</table>

[MeasureLocation]
Measure=Plugin
Plugin=WebParser
Url=[MeasureRainmeter]
StringIndex=1
RegExpSubstitute=1
Substitute="\n":"","^\s+":"","\s+$":""

[MeasureLatitude]
Measure=Plugin
Plugin=WebParser
Url=[MeasureRainmeter]
StringIndex=2

[MeasureLongitude]
Measure=Plugin
Plugin=WebParser
Url=[MeasureRainmeter]
StringIndex=3

[MeasurePostalCode]
Measure=Plugin
Plugin=WebParser
Url=[MeasureRainmeter]
StringIndex=4

[MeterPostalCode]
Meter=STRING
MeasureName=MeasureLocation
MeasureName2=MeasureLatitude
MeasureName3=MeasureLongitude
MeasureName4=MeasurePostalCode
X=0
Y=0
Padding=15,5,15,5
FontColor=220,220,220
SolidColor=0,0,0,150
FontSize=8
FontFace=Segoe UI
StringStyle=BOLD
StringAlign=LEFT
AntiAlias=1
Text=Location: %1#CRLF#Latitude: %2#CRLF#Longitude: %3#CRLF#Postal code: %4
I completely rewrote the RegExp option of the parent WebParser measure. The [MeasureLocation] measure return the location, [MeasureLatitude] and [MeasureLongitude] return the appropriate geographical coordinates, while as I said, if exists, the postal code will be returned by the [MeasurePostalCode] measure.
I'm not completely sure this code will always work well, because I don't know what is the difference when the section with the postal code exists, respectively when it doesn't (yes, I know you've said that the appropriate part of the source code is missing, but maybe there could some other differences as well). Please let me know how is it working.
User avatar
Codger
Posts: 97
Joined: May 29th, 2017, 3:16 pm

Re: Help debugging RrgExp line with look ahead option

Post by Codger »

Thank you for the time you put into this.
I'm probably making really dumb mistakes now as I have been up for over 30 hours which is not as easy as when I was younger and I'm getting a bit punch drunk. I trying to bring my schedule around so I am coding while it is day in the US for the help I need. I'm trying to get this part of the project done in the week before I head back to Canada for a month.

Anyway, I tried to integrate what you wrote into my code. It worked perfectly with an IP with a postal code but when I switched to one without (discovered Singapore never has a postal code which has made testing a lot easier) it dumped a ton of html on the screen.

This is the integration:

Code: Select all

; Location
;

[MeasureWebParseLocation]
Measure=Plugin
Plugin=WebParser
URL=#IPLocationSite#
RegExp=(?siU)<td>City</td>.*<a class=".*" href=".*"></a>(.*)</td>.*</tr>.*<tr>.*<td>Latitude/Longitude</td>.*<td data-loc=".*,.*">(.*),(.*)</td>.*</tr>.*(?(?=.*<tr>).*<td>Postal Code</td>.*<td>(.*)</td>.*</tr>).*</table>

;RegExp=(?siU)City.*<a class="flag .*</a>\n(.*)</td>(?(?=.*<td>Postal Code</td>).*<td>(.*)</td>)
;RegExp=(?siU)City.*<a class="flag .*</a>\n(.*)</td>.*<td>Postal Code</td>.*<td>(.*)</td>

[MeasureLocation]
Measure=Plugin
Plugin=WebParser
URL=[MeasureWebParseLocation]
StringIndex=1
DecodeCharacterReference=1
RegExpSubstitute=1
Substitute="^\s+":""

[MeasureLatitude]
Measure=Plugin
Plugin=WebParser
Url=[MeasureRainmeter]
StringIndex=2

[MeasureLongitude]
Measure=Plugin
Plugin=WebParser
Url=[MeasureRainmeter]
StringIndex=3

[MeasurePostalCode]
Measure=Plugin
Plugin=WebParser
URL=[MeasureWebParseLocation]
StringIndex=4

[MeterLocation]
Meter=String
MeasureName=MeasureLocation
X=2r
Y=69r
FontSize=11
StringStyle=Bold
FontColor=#PureYellow#,255
Text="@ %1"
DynamicVariables=1
UpdateDivider=5


;--- Temp for Testing

[MeterPostalCode]
Meter=String
MeasureName=MeasureLocation
MeasureName2=MeasureLatitude
MeasureName3=MeasureLongitude
MeasureName4=MeasurePostalCode
X=(#BarWidth#+#BackPadding#)
Y=1
FontSize=10
StringStyle=Bold
StringAlign=Right
FontColor=150,150,150,255
Text="%4"
UpdateDivider=5
I'd be happy to post the whole skin as well as complete dumps of a Chicago screen and a Singapore screen if that would help. I really want to get this part behind me as I am way behind. Thank you ever so much.
[hr][/hr][hr][/hr]
"If you are the smartest one in the room, you are in the wrong room."
User avatar
Codger
Posts: 97
Joined: May 29th, 2017, 3:16 pm

Re: Help debugging RrgExp line with look ahead option

Post by Codger »

Oh:
IPLocationSite="http://ipinfo.io/"
[hr][/hr][hr][/hr]
"If you are the smartest one in the room, you are in the wrong room."
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help debugging RrgExp line with look ahead option

Post by balala »

Codger wrote:I'm probably making really dumb mistakes now as I have been up for over 30 hours which is not as easy as when I was younger and I'm getting a bit punch drunk. I trying to bring my schedule around so I am coding while it is day in the US for the help I need. I'm trying to get this part of the project done in the week before I head back to Canada for a month.
O-ho. Go and get some rest. :welcome:
Codger wrote:Anyway, I tried to integrate what you wrote into my code. It worked perfectly with an IP with a postal code but when I switched to one without (discovered Singapore never has a postal code which has made testing a lot easier) it dumped a ton of html on the screen.

I'd be happy to post the whole skin as well as complete dumps of a Chicago screen and a Singapore screen if that would help. I really want to get this part behind me as I am way behind. Thank you ever so much.
Please do. Because the posted URL shows some information, based on the local IP address. As such, I don't know how could I make it to get a source without a postal code, because I do get one. So, I'm not sure how to check what's going on, when there is no postal code.
User avatar
Codger
Posts: 97
Joined: May 29th, 2017, 3:16 pm

Re: Help debugging RrgExp line with look ahead option

Post by Codger »

I'd love to get some rest but I need to power through another 8 hours. Then exactly 8 hours sleep and I'll be halfway around. Repeat once more and I'll be lined up with the US and home. And this is the only thing going to keep these eyes open. :confused:

Okay, first the files:

Traffic.ini

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
Blur=1
MiddleMouseDownAction=!RainmeterDeactivateConfig


[Metadata]
Name=Traffic
Author=Codger
Information=My second widget
Version=0.2.2
License=Free to all to do with as they like

 
;   Notes: This widget makes use of three websites:
;
;   http://www.Bing.com is called every 3 seconds to test Ping.
;   http://icanhazip.com is called every 90 seconds to determine External IP
;   http://ipinfo.io/ is called when ever the External IP status changes
;

[Variables]
; Static Variables
@include=#@#Common.inc
BackHeight=216

BarBackColor=50,50,50,80
BarTextColor=#PureWhite#,255
DownloadColor=#DarkGreen#,255
UploadColor=#BurntOrange#,255
OverloadColor=#PureRed#,255
PingColor=#PureBlue#,255
PingHighColor=#RedOrange#,255
PingOverloadColor=#PureRed#,255
OfflineColor=255,0,0,255

;-- Ranges
HighestLikelyTraffic=2750000

;-- Ping 
PingSite="www.bing.com"
HighestPing=300

;-- External IP
IPSite="http://icanhazip.com"

;-- Location of External IP
IPLocationSite="http://ipinfo.io/"

;---
; dynamic variables
IPlast=XXX.XXX.XXX.XXX

PingBarPic=#@#images\PingBar.png
PingBarTimeOutPic=#@#images\PingBarTimeOutPic.png
BarPicHeight=21

[Background]
Meter=Shape
Shape=Rectangle 0,0,(#BarWidth# + (#BackPadding#*2) + 1),#BackHeight# | Fill Color #BackColor# | StrokeWidth 1 | Stroke Color #BackBorder#
UpdateDivider=-1

;
; PIA Status
; Just displays a logo at the moment.
;Future spot for PIA and LeapIP status indication
;
[PIAStatus]
Meter=Image
ImageName=#@#images\PIAGreen.png
W=32
H=32
Y=5r
X=(((#BarWidth#/2) + #BackPadding#/2)-8)

;
; Ext IP

[MeasureExtIP]
Measure=Plugin
Plugin=WebParser
Url=#IPSite#
RegExp="(?siU)^(.*)$"
StringIndex=1
UpdateRate=90
FinishAction=[!EnableMeasure MeasureIPChangeCheck][!UpdateMeasure MeasureIPChangeCheck]

[MeasureIPChangeCheck]
Measure=Plugin
Plugin=WebParser
Url=[MeasureExtIP]
StringIndex=1
IfMatch=#IPLast#
IfNotMatchAction=[!SetVariable IPLast "[MeasureExtIP]"][!CommandMeasure MeasureWebParseLocation Update]
IfMatchMode=1
DynamicVariables=1
Disabled=1

[MeterExtIP]
Meter=String
MeasureName=MeasureExtIP
X=#BackPadding#
Y=15r
FontSize=10
StringStyle=Bold
FontColor=#PureYellow#,255
Text="Ext IP: %1"

;
; Online

[Internet]
Measure=Plugin
Plugin=SysInfo
SysInfoType=INTERNET_CONNECTIVITY
SysInfoData=Best
UpdateDivider=1

[InternetStatus]
Measure=String
String=Status: [Internet]
Substitute="-1":"Offline", "1":"Online"
DynamicVariables=1
UpdateDivider=1

[MeterInternetStatus]
Meter=String
MeasureName=InternetStatus
X=(#BarWidth#+#BackPadding#)
Y=r
FontSize=10
StringStyle=Bold
StringAlign=Right
FontColor=150,150,150,255
InlineSetting=Color | #OfflineColor#
InlinePattern=Offline
DynamicVariables=1
;!Redraw

[MeterInternetStatus]
Meter=String
MeasureName=InternetStatus
X=(#BarWidth#+#BackPadding#)
Y=r
FontSize=10
StringStyle=Bold
StringAlign=Right
FontColor=150,150,150,255
InlineSetting=Color | #OfflineColor#
InlinePattern=Offline
DynamicVariables=1

; 1st
; Ping

[MeasurePing]
Measure=Plugin
Plugin=PingPlugin
DestAddress=#PingSite#
Timeout=3000
UpdateRate=3
FinishAction=[!SetOption MeterPingBar BarImage #PingBarPic#][!UpdateMeter "MeterPingBar"][!UpdateMeter "MeterPing"]
TimeoutAction=[!SetOption MeterPingBar BarImage #PingBarTimeOutPic#][!UpdateMeter "MeterPingBar"][!UpdateMeter "MeterPing"]

[BoundPing]
Measure=Calc
MinValue=0
MaxValue=#HighestPing#
Formula=MeasurePing
;IfEqualValue=30000
;IfEqualAction=
; Internet Offline ^

[FormatPing]
Measure=String
MeasureName=Internet
Substitute "-1" : "Offline", "1" : "Ping: %1ms"

[MeterPingBar]
Meter=BAR
MeasureName=BoundPing
X=#BackPadding#
Y=20r
W=#BarWidth#
H=#BarPicHeight#
SolidColor=#BarBackColor#
BarImage=#PingBarPic#
BarOrientation=Horizontal
BevelType=1
UpdateDivider=-1

[MeterPing]
Meter=String
MeasureName=BoundPing
X=4r
Y=3r
FontSize=10
StringStyle=Bold
FontColor=#BarTextColor#
Text=Ping: %1ms
DynamicVariables=1
UpdateDivider=-1

; 2nd
; Current Upload Traffic

[MeasureUploadTraffic]
Measure=NetOut
Interface=Best
AutoScale=2

[BoundUploadTraffic]
Measure=Calc
MinValue=0
MaxValue=#HighestLikelyTraffic#
Formula=MeasureUploadTraffic

[MeterUploadBar]
Meter=BAR
MeasureName=BoundUploadTraffic
X=-4r
Y=25r
W=#BarWidth#
H=21
MinValue=0
MaxValue=#HighestLikelyTraffic#
BarColor=#UploadColor#
SolidColor=#BarBackColor#
BarOrientation=Horizontal
BevelType=1

[MeterUploadText]
Meter=String
MeasureName=MeasureUploadTraffic
X=4r
Y=3r
FontSize=10
StringStyle=Bold
FontColor=#BarTextColor#
AutoScale=1
NumOfDecimals=1
Text="Upload: %1"

; 3rd
; Current Download Traffic

[MeasureDownloadTraffic]
Measure=NetIn
Interface=Best
AutoScale=2

[BoundDownloadTraffic]
Measure=Calc
MinValue=0
MaxValue=#HighestLikelyTraffic#
Formula=MeasureDownloadTraffic
Percentual=1

[MeterDownloadBar]
Meter=BAR
MeasureName=BoundDownloadTraffic
X=-4r
Y=25r
W=#BarWidth#
H=21
MinValue=0
MaxValue=#HighestLikelyTraffic#
BarColor=#DownloadColor#
SolidColor=#BarBackColor#
BarOrientation=Horizontal
BevelType=1

[MeterDownloadText]
Meter=String
MeasureName=MeasureDownloadTraffic
X=4r
Y=3r
FontSize=10
StringStyle=Bold
FontColor=#BarTextColor#
AutoScale=1
NumOfDecimals=1
Text="Download: %1"

;
; Network Traffic Histograph

[MeterUploadHistogram]
Meter=Histogram
MeasureName=BoundUploadTraffic
Flip=1
X=-4r
Y=59r
W=#BarWidth#
H=30
PrimaryColor=#UploadColor#
SolidColor=#BarBackColor#
BevelType=1
AntiAlias=1

[MeterDownloadHistogram]
Meter=Histogram
MeasureName=BoundDownloadTraffic
X=r
Y=-34r
W=#BarWidth#
H=32
PrimaryColor=#DownloadColor#
SolidColor=#BarBackColor#
BevelType=1
AntiAlias=1

; Location
;

[MeasureWebParseLocation]
Measure=Plugin
Plugin=WebParser
URL=#IPLocationSite#
RegExp=(?siU)<td>City</td>.*<a class=".*" href=".*"></a>(.*)</td>.*</tr>.*<tr>.*<td>Latitude/Longitude</td>.*<td data-loc=".*,.*">(.*),(.*)</td>.*</tr>.*(?(?=.*<tr>).*<td>Postal Code</td>.*<td>(.*)</td>.*</tr>).*</table>

;RegExp=(?siU)City.*<a class="flag .*</a>\n(.*)</td>(?(?=.*<td>Postal Code</td>).*<td>(.*)</td>)
;RegExp=(?siU)City.*<a class="flag .*</a>\n(.*)</td>.*<td>Postal Code</td>.*<td>(.*)</td>

[MeasureLocation]
Measure=Plugin
Plugin=WebParser
URL=[MeasureWebParseLocation]
StringIndex=1
DecodeCharacterReference=1
RegExpSubstitute=1
Substitute="^\s+":""

[MeasureLatitude]
Measure=Plugin
Plugin=WebParser
Url=[MeasureRainmeter]
StringIndex=2

[MeasureLongitude]
Measure=Plugin
Plugin=WebParser
Url=[MeasureRainmeter]
StringIndex=3

[MeasurePostalCode]
Measure=Plugin
Plugin=WebParser
URL=[MeasureWebParseLocation]
StringIndex=4

[MeterLocation]
Meter=String
MeasureName=MeasureLocation
X=2r
Y=69r
FontSize=11
StringStyle=Bold
FontColor=#PureYellow#,255
Text="@ %1"
DynamicVariables=1
UpdateDivider=5


;--- Temp for Testing

[MeterPostalCode]
Meter=String
MeasureName=MeasureLocation
MeasureName2=MeasureLatitude
MeasureName3=MeasureLongitude
MeasureName4=MeasurePostalCode
X=(#BarWidth#+#BackPadding#)
Y=1
FontSize=10
StringStyle=Bold
StringAlign=Right
FontColor=150,150,150,255
Text="%4"
UpdateDivider=5
Common.inc:

Code: Select all

[Variables]
; Static Variables
BackPadding=15
BarWidth=330
BackColor=25,25,25,200
BackBorder=255,255,0,50

PureBlue=0,0,255
PureRed=255,0,0
PureGreen=0,255,0
PureYellow=255,255,0
PureWhite=255,255,255
BurntOrange=153,76,0
MediumOrange=255,128,0
RedOrange=255,51,51
DarkGreen=0,102,0
MediumGrey=25,25,25
PureWhite=255,255,255

FontFace=Microsoft Sans Serif
FontColor=#PureWhite#,240
FontSize=10
HTML Dump with Postal Code:

Code: Select all

<html><head>
    <title>IP Address Details - ipinfo.io</title>


    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="IP Geolocation, Hostname, Network Owner and More. Comprehensive IP Address Information and REST API from ipinfo.io">

    <link href="/static/favicon.ico?v2" rel="shortcut icon" type="image/x-icon">
    <link href="/static/favicon.ico?v2" rel="icon" type="image/x-icon">

    <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600|Montserrat|Droid+Sans+Mono" rel="stylesheet">
    <!-- <link href='https://fonts.googleapis.com/css?family=Lato:400,700|Droid+Sans+Mono' rel='stylesheet' type='text/css'> -->
    <link href="https://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.3/normalize.min.css" rel="stylesheet" type="text/css">
    <link href="/static/dist/index.css" rel="stylesheet" type="text/css">
    <link href="/static/flags.css" rel="stylesheet" type="text/css">
    <link href="/static/banner.css" rel="stylesheet" type="text/css">

    <link href="/static/layout-styles.css" rel="stylesheet" type="text/css">

    <script src="http://connect.facebook.net/signals/config/1803642776559379?v=2.7.12" async=""></script><script async="" src="//connect.facebook.net/en_US/fbevents.js"></script><script type="text/javascript" async="" src="http://tag.marinsm.com/serve/561152017c2d2e055400003d.js"></script><script async="" src="//www.google-analytics.com/analytics.js"></script><script src="/static/dist/index.js"></script><style>@media print {#ghostery-purple-box {display:none !important}}</style>

    
  <script type="text/javascript" async="" src="http://pixel-geo.prfct.co/tagjs?a_id=51838&source=js_tag"></script></head>
  <body>
      <div id="banner" class="banner" style="display: none">
        <span>
          <div id="extension-image"></div>
          <span id="banner-title"></span>
          <a id="banner-link" href="">Install</a>
          <a id="banner-close" href="" class="close">[close]</a>
        </span>
      </div>

      <header>
        <div id="map-wrapper">
            <h1 id="heading">
  196.52.39.34
</h1>
            <div id="map" class="newyork"></div>
        </div>

        <div id="navbar">

          <div id="nav-logo-holder">
            <a href="/" id="nav-logo" class="active">
              <img id="logoImg" src="/static/dist/images/navbarLogo.svg">
            </a>
          </div>

            <div id="menu-options">
                <a href="/developers">Developers</a>
                <a href="/pricing">Pricing</a>
                <a href="/about">About</a>
                <a href="/customers">Customers</a>
                <a href="https://twitter.com/ipinfoio" target="_blank">Twitter</a>
            </div>

            <div class="signup-container">
              <img class="sign-in-icon" src="/static/images/person-icon.png">
              
              
                <a href="/account/" class="sign-in">Sign In</a>
              
              <div class="vertical-line"></div>
            </div>

            <div id="search-holder">
                <form method="post" action="/" id="ip-search-form">
                  <span>
                    <input name="ip" placeholder="Look up any IP…" tabindex="1" id="search-input" type="text">
                    <input value="GO" type="submit">
                  </span>
                </form>
              </div>
            </div>

      </header>

      <div id="content" class="text-center">
        
<section class="centered-container side-padding">

  
    <p id="google-map-holder">
        <img class="map" src="https://maps.googleapis.com/maps/api/staticmap?center=33.4484,-112.0740&zoom=9&size=640x200&sensor=false" alt="Phoenix, Arizona, United States Map" title="Phoenix, Arizona, United States Map">
    </p>
  

  


  <table class="table table-striped">
    
    

    
      <tbody><tr>
        <td>Hostname</td>
        <td>ip-34-39-52-196.chicago.us.northamericancoax.com</td>
      </tr>
    

    
      <tr>
        <td>Network</td>
        <td><a href="/AS46562">AS46562</a> Total Server Solutions L.L.C.</td>
      </tr>
    

    
      <tr>
        <td>City</td>
        <td>
          <a class="flag flag-us" href="/countries/us"></a>
          Phoenix, Arizona, United States
        </td>
      </tr>
    

    
      <tr>
        <td>Latitude/Longitude</td>
        <td data-loc="33.4484,-112.0740">33.4484,-112.0740</td>
      </tr>
    

    

    
      <tr>
        <td>Postal Code</td>
        <td>85001</td>
      </tr>
    

    
    
      <tr>
        <td>Route</td>
        <td><a href="/AS46562/196.52.39.0/24">196.52.39.0/24</a></td>
      </tr>
    
  </tbody></table>

  

  
  <h2>Network Speed</h2>
  <table class="table table-striped" style="text-align: center;" id="block-table">
    <tbody><tr>
      <th style="width: 33%;">Download Speed</th>
      <th style="width:34%;">Upload Speed</th>
      <th style="width: 33%;">Ping</th>
    </tr>
    <tr>
        <td>20.17 Mbps</td>
        <td>9.65 Mbps</td>
        <td>65.86 ms</td>
    </tr>
    </tbody></table>
    <p>The average network speed for <b>Total Server Solutions L.L.C.</b> in <b>Phoenix</b> is shown above. See how your own network speed compares at <a rel="nofollow" href="/speedtest">speedsmart.net</a>.</p> 
  

  

</section>

<div id="banner-section">
  <div id="feature-centered">
    <div class="feature">
      <div class="banner-item-header varying-height-header">Try our JSON API from the command line.</div>
      <div class="reliability-description">Get started with <code>curl ipinfo.io</code> or see our <a href="/developers">developer documentation</a> for more details.</div>
    </div>

    <div class="feature">
      <div class="banner-item-header varying-height-header">Free for small projects. Pay as you grow.</div>
      <div class="reliability-description">Our API is free for up to 1,000 requests per day. See our <a href="/pricing">pricing</a> details if you need more.</div>
    </div>

    <div class="feature">
      <div class="banner-item-header varying-height-header">A million uses.</div>
      <div class="reliability-description">You can use ipinfo to
          <a href="/developers/filtering-out-bot-traffic">filter out bot traffic</a>,
          <a href="/developers/customize-content-based-on-country">customize content based on visitor's location</a>,
          <a href="/developers/full-country-name">display full country names</a>,
          <a href="/developers/bulk-lookup">perform bulk IP geolocation</a>, and more.</div>
    </div>
  </div>
</div>


      </div>

      <footer class="text-center">
        <div class="footer-holder">
          <div class="footer-row row-one">
            <div class="footer-column"><a href="/developers">Developers</a></div>
            <div class="footer-divider"></div>
            <div class="footer-column footer-middle"><a href="/pricing">Pricing</a></div>
            <div class="footer-divider"></div>
            <div class="footer-column"><a href="/about">About</a></div>
          </div>
          <div id="footer-icon"></div>
          <div class="footer-row row-two">
            <div class="footer-column"><a href="/terms">Terms</a></div>
            <div class="footer-divider"></div>
            <div class="footer-column footer-middle"><a href="/contact">Contact</a></div>
            <div class="footer-divider"></div>
            <div class="footer-column"><a href="https://twitter.com/ipinfoio">Twitter</a></div>
          </div>
        </div>
        <!-- <table id = "footer-table">
          <nav>
            <tr>
              <td><a href="/developers">Developers</a></td>
              <td class = "footer-bullet"></td>
              <td><a href="/pricing">Pricing</a></td>
              <td class = "footer-bullet"></td>
              <td><a href = "/about">About</a></td>
              <td id = "footer-logo"></td>
              <td><a href = "/terms">Terms</a></td>
              <td class = "footer-bullet"></td>
              <td><a href = "/contact">Contact</a></td>
              <td class = "footer-bullet"></td>
              <td><a href = "https://twitter.com/ipinfoio">Twitter</a></td>
            </tr>
          </nav>
        </table> -->
      </footer>

    <script type="text/javascript">
       (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
       (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
       m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
       })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
       ga('create', 'UA-2336519-21', 'ipinfo.io');
       ga('send', 'pageview');
    </script>

    <script type="text/javascript">
      (function() {
        window._pa = window._pa || {};
        // _pa.orderId = "myOrderId"; // OPTIONAL: attach unique conversion identifier to conversions
        // _pa.revenue = "19.99"; // OPTIONAL: attach dynamic purchase values to conversions
        // _pa.productId = "myProductId"; // OPTIONAL: Include product ID for use with dynamic ads
        var pa = document.createElement('script'); pa.type = 'text/javascript'; pa.async = true;
        pa.src = ('https:' == document.location.protocol ? 'https:' : 'http:') + "//tag.marinsm.com/serve/561152017c2d2e055400003d.js";
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(pa, s);
      })();
    </script>

      <script type="text/javascript">

          function closeBanner(key) {
              $('#banner').hide();
              localStorage.setItem(key, true);
          }

          function openLinkInNewTab(url) {
              window.open(url, "_blank").focus();
          }

          function getMobileOperatingSystem() {
              var userAgent = navigator.userAgent || navigator.vendor || window.opera;
              if( userAgent.match( /iPad/i ) || userAgent.match( /iPhone/i ) || userAgent.match( /iPod/i ) ) {
                  return 'iOS';
              } else if( userAgent.match( /Android/i ) ) {
                  return 'Android';
              } else {
                  return 'unknown';
              }
          }

          function onClick(id, fn) {
              $(id).click(function (e) {
                  e.stopImmediatePropagation();
                  e.preventDefault();
                  fn();
              });
          }

          $(function () {
              var mobileOs = getMobileOperatingSystem();
              var isMobileVisible = !localStorage.getItem("mobile_showed");
              var isExtVisible = !localStorage.getItem("extension_showed");
              var isChrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor) && !(typeof window.orientation !== 'undefined');

              var link = null;
              var text = null;
              var key = null;

              if (isExtVisible && isChrome) {
                  link = 'https://chrome.google.com/webstore/detail/ipinfoio-website-ip-addre/dfdphlgjcfobnklpiiobcfmbdnmihjpo?hl=en';
                  text = 'Try our browser extension!';
                  key = 'extension_showed';
              }
              if (isMobileVisible && mobileOs === 'Android') {
                  link = 'https://play.google.com/store/apps/details?id=io.ipinfo.android&hl=en';
                  text = 'Try our mobile app!';
                  key = 'mobile_showed';
              }
              if (isMobileVisible && mobileOs === 'iOS') {
                  link = 'https://itunes.apple.com/tt/app/ipinfo/id917634022?mt=8';
                  text = 'Try our mobile app!';
                  key = 'mobile_showed';
              }

              if (link && text && key) {
                  $("#banner-title").text(text);

                  onClick("#banner-link", function () {
                      openLinkInNewTab(link);
                      closeBanner(key);
                  });

                  onClick("#banner-close", function () {
                      closeBanner(key);
                  });

                  $("#banner").show();
              }

              $('#ip-search-form').on('submit', function (e) {
                location.href = '/' + $('#search-input').val();
                e.preventDefault();
              })
          });
      </script>

  

</body></html>
And Singapore page:

Code: Select all

<html><head>
    <title>IP Address Details - ipinfo.io</title>


    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="IP Geolocation, Hostname, Network Owner and More. Comprehensive IP Address Information and REST API from ipinfo.io">

    <link href="/static/favicon.ico?v2" rel="shortcut icon" type="image/x-icon">
    <link href="/static/favicon.ico?v2" rel="icon" type="image/x-icon">

    <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600|Montserrat|Droid+Sans+Mono" rel="stylesheet">
    <!-- <link href='https://fonts.googleapis.com/css?family=Lato:400,700|Droid+Sans+Mono' rel='stylesheet' type='text/css'> -->
    <link href="https://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.3/normalize.min.css" rel="stylesheet" type="text/css">
    <link href="/static/dist/index.css" rel="stylesheet" type="text/css">
    <link href="/static/flags.css" rel="stylesheet" type="text/css">
    <link href="/static/banner.css" rel="stylesheet" type="text/css">

    <link href="/static/layout-styles.css" rel="stylesheet" type="text/css">

    <script src="http://connect.facebook.net/signals/config/1803642776559379?v=2.7.12" async=""></script><script async="" src="//connect.facebook.net/en_US/fbevents.js"></script><script type="text/javascript" async="" src="http://tag.marinsm.com/serve/561152017c2d2e055400003d.js"></script><script async="" src="//www.google-analytics.com/analytics.js"></script><script src="/static/dist/index.js"></script><style>@media print {#ghostery-purple-box {display:none !important}}</style>

    
  <script type="text/javascript" async="" src="http://pixel-geo.prfct.co/tagjs?a_id=51838&source=js_tag"></script></head>
  <body>
      <div id="banner" class="banner" style="display: none">
        <span>
          <div id="extension-image"></div>
          <span id="banner-title"></span>
          <a id="banner-link" href="">Install</a>
          <a id="banner-close" href="" class="close">[close]</a>
        </span>
      </div>

      <header>
        <div id="map-wrapper">
            <h1 id="heading">
  196.52.34.27
</h1>
            <div id="map" class="dubai"></div>
        </div>

        <div id="navbar">

          <div id="nav-logo-holder">
            <a href="/" id="nav-logo" class="active">
              <img id="logoImg" src="/static/dist/images/navbarLogo.svg">
            </a>
          </div>

            <div id="menu-options">
                <a href="/developers">Developers</a>
                <a href="/pricing">Pricing</a>
                <a href="/about">About</a>
                <a href="/customers">Customers</a>
                <a href="https://twitter.com/ipinfoio" target="_blank">Twitter</a>
            </div>

            <div class="signup-container">
              <img class="sign-in-icon" src="/static/images/person-icon.png">
              
              
                <a href="/account/" class="sign-in">Sign In</a>
              
              <div class="vertical-line"></div>
            </div>

            <div id="search-holder">
                <form method="post" action="/" id="ip-search-form">
                  <span>
                    <input name="ip" placeholder="Look up any IP…" tabindex="1" id="search-input" type="text">
                    <input value="GO" type="submit">
                  </span>
                </form>
              </div>
            </div>

      </header>

      <div id="content" class="text-center">
        
<section class="centered-container side-padding">

  
    <p id="google-map-holder">
        <img class="map" src="https://maps.googleapis.com/maps/api/staticmap?center=1.2855,103.8565&zoom=9&size=640x200&sensor=false" alt="Singapore, Central Singapore Community Development Council, Singapore Map" title="Singapore, Central Singapore Community Development Council, Singapore Map">
    </p>
  

  


  <table class="table table-striped">
    
    

    
      <tbody><tr>
        <td>Hostname</td>
        <td>ip-27-34-52-196.sg.asianpacifictelephone.com</td>
      </tr>
    

    
      <tr>
        <td>Network</td>
        <td><a href="/AS36351">AS36351</a> SoftLayer Technologies Inc.</td>
      </tr>
    

    
      <tr>
        <td>City</td>
        <td>
          <a class="flag flag-sg" href="/countries/sg"></a>
          Singapore, Central Singapore Community Development Council, Singapore
        </td>
      </tr>
    

    
      <tr>
        <td>Latitude/Longitude</td>
        <td data-loc="1.2855,103.8565">1.2855,103.8565</td>
      </tr>
    

    

    

    
    
      <tr>
        <td>Route</td>
        <td><a href="/AS36351/196.52.34.0/24">196.52.34.0/24</a></td>
      </tr>
    
  </tbody></table>

  

  

  

</section>

<div id="banner-section">
  <div id="feature-centered">
    <div class="feature">
      <div class="banner-item-header varying-height-header">Try our JSON API from the command line.</div>
      <div class="reliability-description">Get started with <code>curl ipinfo.io</code> or see our <a href="/developers">developer documentation</a> for more details.</div>
    </div>

    <div class="feature">
      <div class="banner-item-header varying-height-header">Free for small projects. Pay as you grow.</div>
      <div class="reliability-description">Our API is free for up to 1,000 requests per day. See our <a href="/pricing">pricing</a> details if you need more.</div>
    </div>

    <div class="feature">
      <div class="banner-item-header varying-height-header">A million uses.</div>
      <div class="reliability-description">You can use ipinfo to
          <a href="/developers/filtering-out-bot-traffic">filter out bot traffic</a>,
          <a href="/developers/customize-content-based-on-country">customize content based on visitor's location</a>,
          <a href="/developers/full-country-name">display full country names</a>,
          <a href="/developers/bulk-lookup">perform bulk IP geolocation</a>, and more.</div>
    </div>
  </div>
</div>


      </div>

      <footer class="text-center">
        <div class="footer-holder">
          <div class="footer-row row-one">
            <div class="footer-column"><a href="/developers">Developers</a></div>
            <div class="footer-divider"></div>
            <div class="footer-column footer-middle"><a href="/pricing">Pricing</a></div>
            <div class="footer-divider"></div>
            <div class="footer-column"><a href="/about">About</a></div>
          </div>
          <div id="footer-icon"></div>
          <div class="footer-row row-two">
            <div class="footer-column"><a href="/terms">Terms</a></div>
            <div class="footer-divider"></div>
            <div class="footer-column footer-middle"><a href="/contact">Contact</a></div>
            <div class="footer-divider"></div>
            <div class="footer-column"><a href="https://twitter.com/ipinfoio">Twitter</a></div>
          </div>
        </div>
        <!-- <table id = "footer-table">
          <nav>
            <tr>
              <td><a href="/developers">Developers</a></td>
              <td class = "footer-bullet"></td>
              <td><a href="/pricing">Pricing</a></td>
              <td class = "footer-bullet"></td>
              <td><a href = "/about">About</a></td>
              <td id = "footer-logo"></td>
              <td><a href = "/terms">Terms</a></td>
              <td class = "footer-bullet"></td>
              <td><a href = "/contact">Contact</a></td>
              <td class = "footer-bullet"></td>
              <td><a href = "https://twitter.com/ipinfoio">Twitter</a></td>
            </tr>
          </nav>
        </table> -->
      </footer>

    <script type="text/javascript">
       (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
       (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
       m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
       })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
       ga('create', 'UA-2336519-21', 'ipinfo.io');
       ga('send', 'pageview');
    </script>

    <script type="text/javascript">
      (function() {
        window._pa = window._pa || {};
        // _pa.orderId = "myOrderId"; // OPTIONAL: attach unique conversion identifier to conversions
        // _pa.revenue = "19.99"; // OPTIONAL: attach dynamic purchase values to conversions
        // _pa.productId = "myProductId"; // OPTIONAL: Include product ID for use with dynamic ads
        var pa = document.createElement('script'); pa.type = 'text/javascript'; pa.async = true;
        pa.src = ('https:' == document.location.protocol ? 'https:' : 'http:') + "//tag.marinsm.com/serve/561152017c2d2e055400003d.js";
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(pa, s);
      })();
    </script>

      <script type="text/javascript">

          function closeBanner(key) {
              $('#banner').hide();
              localStorage.setItem(key, true);
          }

          function openLinkInNewTab(url) {
              window.open(url, "_blank").focus();
          }

          function getMobileOperatingSystem() {
              var userAgent = navigator.userAgent || navigator.vendor || window.opera;
              if( userAgent.match( /iPad/i ) || userAgent.match( /iPhone/i ) || userAgent.match( /iPod/i ) ) {
                  return 'iOS';
              } else if( userAgent.match( /Android/i ) ) {
                  return 'Android';
              } else {
                  return 'unknown';
              }
          }

          function onClick(id, fn) {
              $(id).click(function (e) {
                  e.stopImmediatePropagation();
                  e.preventDefault();
                  fn();
              });
          }

          $(function () {
              var mobileOs = getMobileOperatingSystem();
              var isMobileVisible = !localStorage.getItem("mobile_showed");
              var isExtVisible = !localStorage.getItem("extension_showed");
              var isChrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor) && !(typeof window.orientation !== 'undefined');

              var link = null;
              var text = null;
              var key = null;

              if (isExtVisible && isChrome) {
                  link = 'https://chrome.google.com/webstore/detail/ipinfoio-website-ip-addre/dfdphlgjcfobnklpiiobcfmbdnmihjpo?hl=en';
                  text = 'Try our browser extension!';
                  key = 'extension_showed';
              }
              if (isMobileVisible && mobileOs === 'Android') {
                  link = 'https://play.google.com/store/apps/details?id=io.ipinfo.android&hl=en';
                  text = 'Try our mobile app!';
                  key = 'mobile_showed';
              }
              if (isMobileVisible && mobileOs === 'iOS') {
                  link = 'https://itunes.apple.com/tt/app/ipinfo/id917634022?mt=8';
                  text = 'Try our mobile app!';
                  key = 'mobile_showed';
              }

              if (link && text && key) {
                  $("#banner-title").text(text);

                  onClick("#banner-link", function () {
                      openLinkInNewTab(link);
                      closeBanner(key);
                  });

                  onClick("#banner-close", function () {
                      closeBanner(key);
                  });

                  $("#banner").show();
              }

              $('#ip-search-form').on('submit', function (e) {
                location.href = '/' + $('#search-input').val();
                e.preventDefault();
              })
          });
      </script>

  

</body></html>
Fingers crossed I did that all correctly and that I didn't forget anything. There are a couple of images but it should run no worse for not having them. Thanks again. And free speech thanks you too.
[hr][/hr][hr][/hr]
"If you are the smartest one in the room, you are in the wrong room."
User avatar
FreeRaider
Posts: 826
Joined: November 20th, 2012, 11:58 pm

Re: Help debugging RrgExp line with look ahead option

Post by FreeRaider »

Code: Select all

RegExp=(?siU)<td>City</td>.*<a class=".*" href=".*"></a>(.*)</td>.*</tr>.*<tr>.*<td>Latitude/Longitude</td>.*<td data-loc=".*,.*">(.*),(.*)</td>.*</tr>.*(?(?=.*<tr>.*<td>Postal).*<td>Postal Code</td>.*<td>(.*)</td>.*</tr>).*</table>
User avatar
Codger
Posts: 97
Joined: May 29th, 2017, 3:16 pm

Re: Help debugging RrgExp line with look ahead option

Post by Codger »

FreeRaider wrote:

Code: Select all

RegExp=(?siU)<td>City</td>.*<a class=".*" href=".*"></a>(.*)</td>.*</tr>.*<tr>.*<td>Latitude/Longitude</td>.*<td data-loc=".*,.*">(.*),(.*)</td>.*</tr>.*(?(?=.*<tr>.*<td>Postal).*<td>Postal Code</td>.*<td>(.*)</td>.*</tr>).*</table>
That works flawlessly. Thank you ever so much. I've saved the other attempts and what they did and will figure out the difference and get better at RegExp on the 29 hour plane ride back home next week. Right now I have to get back on schedule.

Thank you gratefully for your time and slogging through all of that.
[hr][/hr][hr][/hr]
"If you are the smartest one in the room, you are in the wrong room."
User avatar
FreeRaider
Posts: 826
Joined: November 20th, 2012, 11:58 pm

Re: Help debugging RrgExp line with look ahead option

Post by FreeRaider »

Glad to help.

Let us know if you have other issues.
User avatar
Codger
Posts: 97
Joined: May 29th, 2017, 3:16 pm

Re: Help debugging RrgExp line with look ahead option

Post by Codger »

The only other issue with WebParser I am having (that I am aware of) is that it runs fine unless I refresh the skin.

I have two calls to two different websites at two different update rates. I think the problem may lie in that area.
The weird thing is after the refresh the check on the IP address still works fine, but the one we were just working on stops working. Very weird but not something that will come in normal situations so I can work on that on my next trip (when I am older and wiser :D )

And if you are wondering why I check a separate page for the IP when that info is on Location as well is that I check the IP more often than the Location page would prefer of its non-paying customers.

Thank you for all the support - in mind and morale.
[hr][/hr][hr][/hr]
"If you are the smartest one in the room, you are in the wrong room."