Sign in to follow this  
Followers 0
Xenobiologist

_getProvider()

18 posts in this topic

Hi,

does this also work for you? I can only test it for my provider.

#include<Array.au3>
#include<Inet.au3>

Global $my_WAN_IP = _GetIP()
If @error Then ConsoleWrite(@error & @CRLF)
ConsoleWrite('! : ' & $my_WAN_IP & @CRLF)
Global $my_Provider_A = _getProvider($my_WAN_IP)

_ArrayDisplay($my_Provider_A)

Func _getProvider($ip)
    Local $provInfo[4], $fcontent, $re
    If Not StringRegExp($ip, '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}', 0) Then
        SetError(1)
        Return -1
    EndIf
    $fcontent = _INetGetSource('http://www.ip-adress.com/whois/' & $ip)
    If Not @error Then
        $re = StringRegExp($fcontent, '(?<=descr:).*(?=\n)', 3)
        If @error = 0 Then
            $provInfo[0] = StringStripWS($re[0], 1)
            $provInfo[1] = StringStripWS($re[1], 1)
        EndIf
        $re = StringRegExp($fcontent, '(?<=inetnum:)[\d .-]*(?=\n)', 3)
        If @error = 0 Then $provInfo[2] = StringStripWS($re[0], 1)
        $re = StringRegExp($fcontent, '(?<=country:).*(?=\n)', 3)
        If @error = 0 Then $provInfo[3] = StringStripWS($re[0], 1)
        Return $provInfo
    EndIf
    SetError(2)
    Return -1
EndFunc   ;==>_getProvider

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites



Yep it works:

Belgium : Belgacom/Skynet

Share this post


Link to post
Share on other sites

Didn't work for me...

I got:

Row

[0]

[1]

[2]

[3]

:)

Share this post


Link to post
Share on other sites

Works for me (Telia, Sweden), just curious though, what does the ip range in $array[2] mean?


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

Works for me (Telia, Sweden), just curious though, what does the ip range in $array[2] mean?

my guess is that it is the ip range the provider owns, and distributes among the customers..

Mads3n.dk

Share this post


Link to post
Share on other sites

Fails for me: returns empty array.

It does ConsoleWrite my Wan IP OK, but that's it.

I also tested wiyh my provider's IP and it fails too.

So if you want to test with that it's 216.113.192.10

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Hi,

thanks @all for testing. The problem is finding a website which porvides good information. Maybe I have to add some extra StringRegExp for special things.

Mega

Edited by Xenobiologist

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Thanks :)

Share this post


Link to post
Share on other sites

I tested it on a Sprint PCS broadband card and it didn't return any values still looks neat though!


[center][/center]

Share this post


Link to post
Share on other sites

It didn't work for m but I managed to get it working by removing the RegEx and replacing it with a string split then an array search. It was easy to check yours by checking the arrays after each reex. That bloody fuction is getting severly overused anyway.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Hi,

fot those where the function didn't return correct values, please visit the site used in the func and do a test manually and then tell me whether the information provided is correct there. After that I can add then additional RegExp to get the information even if there isn't a descr. string.

Thanks!

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Hi,

fot those where the function didn't return correct values, please visit the site used in the func and do a test manually and then tell me whether the information provided is correct there. After that I can add then additional RegExp to get the information even if there isn't a descr. string.

Thanks!

Mega

It worked fine from the site and like I said, I was able to get the info by using stringsplit instead.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

It worked fine from the site and like I said, I was able to get the info by using stringsplit instead.

Hi,

but what info did you collect? Can you show me? What the site respond and what you need from that.

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

Hi,

but what info did you collect? Can you show me? What the site respond and what you need from that.

Mega

#include<Array.au3>
#include<Inet.au3>

Global $my_WAN_IP = _GetIP()
If @error Then ConsoleWrite(@error & @CRLF)
ConsoleWrite('! : ' & $my_WAN_IP & @CRLF)
;Global $my_Provider_A = _getProvider($my_WAN_IP)
$arr = StringSplit(_INetGetSource('http://www.ip-adress.com/whois/' & $my_WAN_IP), @LF)
;_ArrayDisplay($my_Provider_A)
_ArrayDisplay($arr)

Func _getProvider($ip)
    Local $provInfo[4], $fcontent, $re
    If Not StringRegExp($ip, '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}', 0) Then
        SetError(1)
        Return -1
    EndIf
    $fcontent = _INetGetSource('http://www.ip-adress.com/whois/' & $ip)
    If Not @error Then
        $re = StringRegExp($fcontent, '(?<=descr:).*(?=\n)', 3)
        If @error = 0 Then
            $provInfo[0] = StringStripWS($re[0], 1)
            $provInfo[1] = StringStripWS($re[1], 1)
        EndIf
        $re = StringRegExp($fcontent, '(?<=inetnum:)[\d .-]*(?=\n)', 3)
        If @error = 0 Then $provInfo[2] = StringStripWS($re[0], 1)
        $re = StringRegExp($fcontent, '(?<=country:).*(?=\n)', 3)
        If @error = 0 Then $provInfo[3] = StringStripWS($re[0], 1)
        Return $provInfo
    EndIf
    SetError(2)
    Return -1
EndFunc ;==>_getProvider

Then just use _ArraySearch to get the start and end positions. After that you can work out a RegEx or RegExReplace that only works on those lines. By the way, all I'm pointing out here is that the site returns the proper results but your function fails for me.

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Interesting why it works for some and not others. I just sent him the results that show the html source was returned properly by _InetGetSource, so the only place left for it to fail is in the RegEx(). He may have to get test pages from more than one person to find out where it's really failing.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

Some are asking why it's working on some PC's and not others.

I doubt seriously it will work on most U.S. PC's because of the source content I was reading over (U.S. versus a lot of other countries).

I was looking for a tool that could narrow down searches, and if this was application specific, then you probably don't need to check but once a day maybe.

I found a site that seemed to give what "I" was looking for, but I reached my daily limit before debugging... Then I registered and just didn't feel like messing with it any more.

If someone else would like to finish debugging be my guest.

#include<Array.au3>
#include<Inet.au3>

$aArray = _myGetProvider("")
_ArrayDisplay($aArray)

Func _myGetProvider($nIP = "")
    If $nIP = "" Then
        $aSRE = StringRegExp(_INetGetSource("http://www.aboutmyx.com/AboutMyXApp/AboutMyIP.jsp"), _
            "(?s)(?i)Your IP Address: (\d+\.\d+\.\d+\.\d+)<", 1)
        If IsArray($aSRE) = 0 Then Return SetError(1, 0, 0)
        $nIP = $aSRE[0]
    EndIf
    ;[1] IP, [2] Provider, [3] Country, [4] City
    Local $aReturn[5] = [4, $nIP]
    Local $sSource = _INetGetSource("http://whois.domaintools.com/" & $nIP)
    Local $sLookUp = '<img src="http://img.domaintools.com/flags/.*?" alt=".*?" height="\d+" width="\d+">'
    Local $sExp = ".*?(\w+\s\w*|\w+)\s{2,}(\w+\s\w*|\w+)\s*(\w+\s\w+|\w+).*?<"
    Local $aSRE = StringRegExp($sSource, "(?s)(?i)" & $sLookUp & $sExp, 1)
    If IsArray($aSRE) = 0 Then Return SetError(2, 0, $aReturn)
    $aReturn[2] = $aSRE[1]
    $aReturn[3] = $aSRE[0]
    $aReturn[4] = $aSRE[2]
    
    Local $aProvider = StringRegExp($sSource, "(?s)(?i)orgname:(.*?)<|descr:(.*?)<", 1)
    If IsArray($aProvider) = 0 Then Return SetError(3, 0, $aReturn)
    If StringInStr(StringReplace($aProvider[0], "&nbsp;", ""), $aSRE[2]) Then
        $aReturn[2] = $aSRE[2]
        $aReturn[4] = $aSRE[1]
        MsgBox(0,0,0)
    EndIf
    Return $aReturn 
EndFunc

Edit:

Damn.. I left someones IP address in the param pass (removed) :)

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0