Python Website Scanner Tutorial - 3 - IP Address

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

It can be done like this:

from socket import gethostbyname

def get_ip_address(url)
return gethostbyname(url)

Hope it helps!

Chiab
Автор

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

yevheniilytvynenko
Автор

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


siddharthkumarsah
Автор

I would have used a regular expression. Just search for and return the first match.

lhamil
Автор

You could replace your results line with this:

results =

mohhindersuresh
Автор

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

abeerhussain
Автор

"has address" will not exist for another languages :)

tyubnm
Автор

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

baysunny
Автор

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.

ultimategameplay
Автор

another way using regular expression
import os, re
def get_ip_address(url):
command="host "+url

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)

etharshrouf
Автор

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

mathewscolari
Автор

I get
'host ' is not recognized as an internal or external command,
operable program or batch file.

carson
Автор

import socket

# a simple example

def main():

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

fqdn =

print fqdn

if __name__ == '__main__':
main()

malinwolfhess
Автор

Folks with socket module you have a functioned named gethostbyname()....you can use that to get IP address ...if it does not work you very well have becky videos...enjoy and keep coding

vashisht
Автор

not showing any results, no errors.. :( pls help

alaska
join shbcf.ru