2024-05-21 02:49:04 发布
网友
我的光纤互联网提供商支持UDP上的IPTV。但是,它们不会列出任何地方的频道。在
我已经手动找到了其中的大多数,但是我希望有一个脚本,可以验证一个通道是否是活动的/可用的。在
关于如何在Python中实现这一点有什么想法吗?在
我认为python代码应该如下所示。请注意,不要在Python IDLE中运行它,因为ipRange()将挂起它。在
def ipRange(start_ip, end_ip): start = list(map(int, start_ip.split("."))) end = list(map(int, end_ip.split("."))) temp = start ip_range = [] ip_range.append(start_ip) while temp != end: start[3] += 1 for i in (3, 2, 1): if temp[i] == 256: temp[i] = 0 temp[i-1] += 1 ip_range.append(".".join(map(str, temp))) return ip_range def IPTVSignalTest(ip): # do your test here, return true if IPTV signal, false otherwise return TRUE ip_range = ipRange("192.168.1.0", "192.171.3.25") save_ip = [] for ip in ip_range: if IPTVSignalTest(ip): save_ip.append(ip)
我认为python代码应该如下所示。请注意,不要在Python IDLE中运行它,因为ipRange()将挂起它。在
相关问题 更多 >
编程相关推荐