久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術文章
文章詳情頁

Python獲取指定網段正在使用的IP

瀏覽:5日期:2022-07-02 10:42:32

#!/usr/bin/env python# -*- coding: utf-8 -*-’’’’’ 使用方法樣例 python test20.py 192.168.1.1 (會掃描192.168.1.1-255的ip) 多線程加速后大概十幾秒’’’import platformimport sysimport osimport timeimport threadinglive_ip = 0def get_os(): os = platform.system() if os == 'Windows': return 'n' else: return 'c'def ping_ip(ip_str): cmd = ['ping', '-{op}'.format(op=get_os()), '1', ip_str] output = os.popen(' '.join(cmd)).readlines() for line in output: if str(line).upper().find('TTL') >= 0: print('ip: %s is ok ***' % ip_str) global live_ip live_ip += 1 breakdef find_ip(ip_prefix): ’’’’’ 給出當前的127.0.0 ,然后掃描整個段所有地址 ’’’ threads = [] for i in range(1, 256): ip = ’%s.%s’ % (ip_prefix, i) threads.append(threading.Thread(target=ping_ip, args={ip, })) for i in threads: i.start() for i in threads: i.join()if __name__ == '__main__': print('start time %s' % time.ctime()) cmd_args = sys.argv[1:] args = ''.join(cmd_args) ip_pre = ’.’.join(args.split(’.’)[:-1]) find_ip(ip_pre) print('end time %s' % time.ctime()) print(’本次掃描共檢測到本網絡存在%s臺設備’ % live_ip)

Python獲取指定網段正在使用的IP

以上就是Python獲取指定網段正在使用的IP的詳細內容,更多關于python 獲取網段ip的資料請關注好吧啦網其它相關文章!

標簽: Python 編程
相關文章:
主站蜘蛛池模板: 五大连池市| 宁河县| 兴山县| 霞浦县| 错那县| 乌兰察布市| 安徽省| 楚雄市| 台北县| 璧山县| 大埔区| 陇南市| 正定县| 方城县| 本溪市| 雷山县| 凭祥市| 扎兰屯市| 吐鲁番市| 临高县| 华坪县| 南京市| 松潘县| 山西省| 民县| 永州市| 石河子市| 嘉善县| 什邡市| 榆树市| 灵丘县| 汉中市| 黔东| 雷山县| 招远市| 揭西县| 诸城市| 林甸县| 大城县| 扶绥县| 古交市|