Python Website Scanner Tutorial – 3 – IP Address

Felipe , Cedisalibros.com – The worst service ever! lost all my info – Just host is a scam service that will only give you problems last week I lost all my information because of a server side IP problem I try to restore a backup and found that the didn’t backup for days my service, even if I have the backup Pro plan, and the only answer you get “Seema T We really sorry for the inconvenience you are facing. I have checked it with our higher tech,Only those are the backup available from that date. F Who would respond for this I mean is part of your service? 9:32:13 PM F Right? 9:32:38 PM Seema T Yes its a part of our service we provide you with.” A very bad service not recommended for anyone


Join our community below for all the latest videos and tutorials!

Website – https://thenewboston.com/
Discord – https://discord.gg/thenewboston
GitHub – https://github.com/thenewboston-developers
Reddit – https://www.reddit.com/r/thenewboston/
LinkedIn – https://www.linkedin.com/company/thenewboston-developers/
Facebook – https://www.facebook.com/TheNewBoston-464114846956315/
Twitter – https://twitter.com/thenewboston_og
Instagram – https://www.instagram.com/thenewboston_official/
Twitch – https://www.twitch.tv/thenewboston

TNBC Donations: b6e21072b6ba2eae6f78bc3ade17f6a561fa4582d5494a5120617f2027d38797

thenewboston

21 Comments
  • Mathew Scolari
    Posted at 03:31h, 17 October

    Im getting an error at compile saying that the list index is out of range.

  • liendre
    Posted at 04:05h, 17 October

    It can be done like this:

    from socket import gethostbyname

    def get_ip_address(url)
    return gethostbyname(url)

    Hope it helps!

  • Mohhinder Suresh
    Posted at 05:44h, 17 October

    You could replace your results line with this:

    results = str(process.read()).split()[3]

  • EGN SHOCK
    Posted at 01:21h, 26 October

    is this only for mac?

  • tyubnm564
    Posted at 13:33h, 08 December

    "has address" will not exist for another languages 🙂

  • dhg1234
    Posted at 11:34h, 20 December

    use split(' ') function

  • Tactical Almonds
    Posted at 23:38h, 26 December

    So doing this on windows with ping and its sort of the same. Running into the problem of trying to truncate the final ~22 characters from the results. Any suggestions??

    Edit: I got it to work.

  • Carson
    Posted at 09:29h, 01 January

    Where does he get the ava@computer from?
    I get
    'host ' is not recognized as an internal or external command,
    operable program or batch file.
    I am assuming that is because I dont have the ava@computer thing? I am new to this 🙂

  • malin hess
    Posted at 21:43h, 29 September

    import socket

    # a simple example

    def main():

    # get fully qualified domain name
    ip = raw_input('Enter url ')

    fqdn = socket.gethostbyname(socket.getfqdn(ip))

    print fqdn

    if _name_ == '__main__':
    main()

  • baysunny
    Posted at 05:49h, 01 May

    'host' is not recognized as an internal or external command, operable program or batch file.
    what should i do??

  • Abeer Hussain
    Posted at 07:46h, 01 September

    we can also use socket.gethostbyname() to get ip address

  • Felix Brumm
    Posted at 12:55h, 11 November

    You could Just use grep lol

  • fady mohsen
    Posted at 15:37h, 16 January

    how can i get that ava@computer in windows

  • Alpha Omega
    Posted at 11:36h, 19 January

    C:XXXXXXXPycharmProjectspySCvenvScriptspython.exe C:/XXXXXXX/PycharmProjects/pySC/ip_adress.py
    'host' is not recognized as an internal or external command,
    operable program or batch file.
    Traceback (most recent call last):
    File "C:/XXXXXXX/PycharmProjects/pySC/ip_adress.py", line 11, in <module>
    print(get_ip_address('google.de'))
    File "C:/XXXXXXX/PycharmProjects/pySC/ip_adress.py", line 9, in get_ip_address
    return results[marker:].spltilines()[0]
    AttributeError: 'str' object has no attribute 'spltilines'

  • ethar shrouf
    Posted at 14:07h, 28 May

    another way using regular expression
    import os,re
    def get_ip_address(url):
    command="host "+url
    process=os.popen(command).read()
    pattern="d{1,3}.d{1,3}.d{1,3}.d{1,3}"
    regex = re.compile(pattern)
    test = regex.findall(process)
    for i in test:
    return(i)

  • Siddharth Kumar Sah
    Posted at 18:23h, 09 September

    If you are on Windows and Python, here's one east way to do it:

    import socket

    def get_ip_address(url):
    results = socket.gethostbyname(url)
    return results

    print(get_ip_address('thenewboston.com'))

  • Eugene Lytvynenko
    Posted at 16:18h, 18 January

    You can simply use "dig +short " instead of "host ". That'll give you just an IP

  • C V
    Posted at 20:45h, 24 May

    hi brother

    import socket
    print(socket.gethostbyname('thenewboston.com'))

    this will return ip 54.186.250.79

  • Lenora Leivi
    Posted at 18:09h, 20 July

    not showing any results, no errors.. 🙁 pls help

  • noo no
    Posted at 15:15h, 26 October

    import socket
    socket.gethostbyname('google.com')

  • money man
    Posted at 06:39h, 04 December

    socket.gethostbyname(thenewbosten.com)