I'm trying to figure out how to scan the network for devices which are published by avahi.
#!/usr/bin/python3
from zeroconf import ServiceBrowser, Zeroconf
from time import sleep
class MyListener:
def remove_service(self, zeroconf, type, name):
print("Service % removed" % (name))
def add_service(self, zeroconf, type, name):
info = zeroconf.get_service_info(type, name)
info = str(info)
info = info.split(",")[6]
print(info)
zeroconf = Zeroconf()
listener = MyListener()
browser = ServiceBrowser(zeroconf, "_http._tcp.local.", listener)
try:
sleep(1)
finally:
zeroconf.close()
It works, but it doesn't give me ANY IPv4 address. Output(example):
ServiceInfo(type='_http._tcp.local.', name='Barco ptp-owsserver-2237._http._tcp.local.', address=b'\n\x80Cj', port=80, weight=0, priority=0, server='ptp-owsserver-2237.local.', properties={b'root': b'/'})
Could PLEASE someone tell me how to get the IPv4 Addresses of the devices which are published by avahi in our network?