Filter by Domain or Word using python

160 Views Asked by At

Hello, im searching for some help. I want to filter a print results in python. I use this code:

import socket
addr_range = "192.168.1.%d"
ip_address_up = []
ip_dns = []
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.settimeout(2.0)

for i in range(1, 254):
    try:
        ip = addr_range % i
        ip_dns.append(socket.gethostbyaddr(ip))
        ip_address_up.append(ip)
    except socket.herror as ex:
        pass

print (ip_dns)

by: mouad (edited by me)

So i have a lot of results, and i want to filter them like: just show results if domain is .com.

Or remove results by words, like: the hostname is vodafone for example, and i want if hostname have the word vodafone don't appear.

Thanks!

0

There are 0 best solutions below