Jump to content
youtuber

Question about TCPNameToIP?

Recommended Posts

youtuber

I want to get the ip address of a website
I use this function for this
But it returns false if it is an alternate http or https or no www

$asURL = "www.google.com";No problem

;$asURL = "https://www.google.com";problem
and
;$asURL = "http://www.google.com";problem

MsgBox(0,"",SiteIPGET($asURL))

Func SiteIPGET($aWebsite)
    TCPStartup()
    OnAutoItExitRegister("OnAutoItExit")
    Local $sIPAddress = TCPNameToIP($aWebsite)
    If @error Then
        MsgBox(48, "", "Site Not Reached: " & @error)
        Return False
    Else
      Return $sIPAddress
    EndIf
EndFunc

Func OnAutoItExit()
    TCPShutdown()
EndFunc

 

Share this post


Link to post
Share on other sites
Simpel

Hi.

Try this to strip 'http(s)://' before MsgBox() (untested):

$asURL = StringReplace($asURL, "https://", "")
$asURL = StringReplace($asURL, "http://", "")

Conrad 

  • Like 1

SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

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

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.