我的光纤互联网提供商支持UDP上的IPTV。然而,它们不会列出任何地方的频道。
我已经找到他们中的大多数手动,但希望有一个脚本,可以验证如果一个频道是活动的/可用的。
关于如何在Python中实现这一点,有什么想法吗?
发布于 2012-01-05 01:58:29
我认为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)https://stackoverflow.com/questions/4578764
复制相似问题