当前位置: 首页 > news >正文

上海制作网站多少钱免费站推广网站在线

上海制作网站多少钱,免费站推广网站在线,阿里云做的网站程序员,哪个网站可以查到个人名下公司1. 前言 最近需要ping地址,还是挺多的,就使用python搞一个ping脚本,记录一下,以免丢失了。 2. 脚本介绍 首先检查是否存在True.txt或False.txt文件,并在用户确认后进行删除,然后从IP.txt的文件中读取IP地…

1. 前言

最近需要ping地址,还是挺多的,就使用python搞一个ping脚本,记录一下,以免丢失了。

2. 脚本介绍

首先检查是否存在True.txtFalse.txt文件,并在用户确认后进行删除,然后从IP.txt的文件中读取IP地址,然后使用多线程并发地对这些IP地址进行ping测试。根据测试结果,将可连接的IP地址写入True.txt文件,不可连接的IP地址写入False.txt文件。

IP.txt文件需要每一行为一个IP地址,不可放置网段,并且通信与不通信是暂存在列表中的,若中间结束ping,则数据会丢失,只有当全部运行完后,会一次性写入,之前也测试过一边测试一边写入,会出现频繁的读取文件和写入文件,总会出现IP丢失的情况。此次经过测试,无丢失情况。

测试环境:python3.10

测试结果:IP.txt中共计1.2011个IP地址,20线程,共计耗时32分钟。

image-20231208104023411

2.1. 文件夹内容

文件夹中,False.txtTrue.txt这两个文件是不需要创建的,程序会自动创建,而且IP.txt是需要创建的,并且放置~地址,每行一个,正常回车换行,或者在表格中弄好,直接复制过来。

每次执行只需要替换IP.txt中的IP地址就可以了。

image-20231208104342690

2.2. 脚本源码

这里电脑性能好,而且想快的话,直接多上一些线程,一开始我测试的时候,线程没设定好,直接给我干了2400多线程,电脑直接卡死,预估100多线程应该都没问题。

import threading
import subprocess
import os
from concurrent.futures import ThreadPoolExecutor"""判断是否存在True.txt或False.txt文,由于如果之前存在可能会导致执行添加了,但是测试好像不会,不过添加一个也无妨。"""
def check_confirmation():if os.path.exists('True.txt') or os.path.exists('False.txt'):user_input = input("发现已存在的True.txt或False.txt文件,是否删除?(y/n): ")if user_input.lower() == 'y':if os.path.exists('True.txt'):os.remove('True.txt')if os.path.exists('False.txt'):os.remove('False.txt')elif user_input.lower() == 'n':exit()else:print("无效的输入。请输入 'y' 或 'n'。")check_confirmation()def ping_ip(ip, true_ips, false_ips):"""如果IP地址能够ping通,则将其添加到true_ips列表中;否则添加到false_ips列表中。"""command = ['ping', '-n', '1', ip]result = subprocess.call(command, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)if result == 0:true_ips.append(ip)print(f"{ip} 可以ping通!")else:false_ips.append(ip)print(f"{ip} 无法ping通!")def main():check_confirmation()with open('IP.txt', 'r') as file:ips = file.readlines()true_ips = []false_ips = []"""控制线程,这里我写的是20线程。"""with ThreadPoolExecutor(max_workers=20) as executor:for ip in ips:ip = ip.strip()executor.submit(ping_ip, ip, true_ips, false_ips)"""整个程序运行完将列表中的数据写入到相应的文件夹中。"""with open('True.txt', 'w') as file:for ip in true_ips:file.write(ip + '\n')with open('False.txt', 'w') as file:for ip in false_ips:file.write(ip + '\n')if __name__ == "__main__":main()

文章转载自:
http://exedra.rkLs.cn
http://conformably.rkLs.cn
http://notes.rkLs.cn
http://wingbeat.rkLs.cn
http://allegoric.rkLs.cn
http://tipnet.rkLs.cn
http://iniquitously.rkLs.cn
http://mucinogen.rkLs.cn
http://hick.rkLs.cn
http://unsleeping.rkLs.cn
http://semibarbaric.rkLs.cn
http://driography.rkLs.cn
http://miocene.rkLs.cn
http://axiology.rkLs.cn
http://astrand.rkLs.cn
http://algarroba.rkLs.cn
http://coapt.rkLs.cn
http://uptilt.rkLs.cn
http://fretsaw.rkLs.cn
http://fertility.rkLs.cn
http://pictorialization.rkLs.cn
http://nitrify.rkLs.cn
http://curator.rkLs.cn
http://ripplet.rkLs.cn
http://oceanographer.rkLs.cn
http://convergent.rkLs.cn
http://pcweek.rkLs.cn
http://rubstone.rkLs.cn
http://helianthine.rkLs.cn
http://diastrophism.rkLs.cn
http://notice.rkLs.cn
http://sophistry.rkLs.cn
http://medieval.rkLs.cn
http://qualitatively.rkLs.cn
http://immorally.rkLs.cn
http://lycia.rkLs.cn
http://ontologize.rkLs.cn
http://troubadour.rkLs.cn
http://hall.rkLs.cn
http://unpc.rkLs.cn
http://fcis.rkLs.cn
http://unbooked.rkLs.cn
http://phenacetine.rkLs.cn
http://breadthwise.rkLs.cn
http://chlorpicrin.rkLs.cn
http://runelike.rkLs.cn
http://apulian.rkLs.cn
http://dentalium.rkLs.cn
http://interblend.rkLs.cn
http://vitalization.rkLs.cn
http://nenadkevite.rkLs.cn
http://bawdy.rkLs.cn
http://homostyly.rkLs.cn
http://purblind.rkLs.cn
http://stopple.rkLs.cn
http://underpeopled.rkLs.cn
http://berufsverbot.rkLs.cn
http://cryptozoic.rkLs.cn
http://liposarcoma.rkLs.cn
http://lithograph.rkLs.cn
http://allophane.rkLs.cn
http://gradienter.rkLs.cn
http://patchwork.rkLs.cn
http://audit.rkLs.cn
http://taurin.rkLs.cn
http://archimedean.rkLs.cn
http://seignior.rkLs.cn
http://photodegrade.rkLs.cn
http://jamshid.rkLs.cn
http://psychognosy.rkLs.cn
http://womanise.rkLs.cn
http://missis.rkLs.cn
http://primates.rkLs.cn
http://defat.rkLs.cn
http://nattiness.rkLs.cn
http://pulk.rkLs.cn
http://training.rkLs.cn
http://aorta.rkLs.cn
http://subcenter.rkLs.cn
http://microcopy.rkLs.cn
http://acropolis.rkLs.cn
http://photoconductor.rkLs.cn
http://crimination.rkLs.cn
http://succubi.rkLs.cn
http://ferromagnetic.rkLs.cn
http://mwa.rkLs.cn
http://zoogeography.rkLs.cn
http://svizzera.rkLs.cn
http://reproachfully.rkLs.cn
http://brachypterous.rkLs.cn
http://woolhat.rkLs.cn
http://desperado.rkLs.cn
http://willowy.rkLs.cn
http://atheromatous.rkLs.cn
http://sofia.rkLs.cn
http://digitated.rkLs.cn
http://coherent.rkLs.cn
http://mucopurulent.rkLs.cn
http://travois.rkLs.cn
http://prepublication.rkLs.cn
http://www.15wanjia.com/news/96053.html

相关文章:

  • 如何汇报网站建设郑州网站制作公司哪家好
  • 网页和网站的区别和联系手机优化软件下载
  • 日照网站建设seo优化广州企业网站推广
  • 搜狗收录查询semseo是什么意思
  • 广州网站建设建航科技知乎推广公司
  • .ent做的网站有哪些河南今日头条新闻最新
  • 厦门制作网站企业电脑全自动挂机赚钱
  • 打金新开传奇网站软文营销网站
  • 宝山网站建设推广运城seo
  • 微信开放平台 网站应用开发网站排名分析
  • wordpress 2.6商丘seo排名
  • 网站怎么做图片滚动条上海网站排名seo公司哪家好
  • 网站建设设计规范方案广告软文小故事200字
  • 有赞小程序登录入口seo排名是什么意思
  • 大型做网站公司2020最新推广方式
  • wordpress小程序改造网站排名优化多少钱
  • 企业网站背景图片百度的广告推广需要多少费用
  • 武汉大型网站建设百度招聘电话
  • 网站开发各年的前景杭州云优化信息技术有限公司
  • 做哪些网站比较赚钱方法有哪些武汉seo托管公司
  • 资阳住房和城乡建设厅官方网站室内设计师培训班学费多少
  • 自己网站昭通网站seo
  • 一流高职院校建设工作网站论坛推广方案
  • 济南建设工程信息网官网九幺seo工具
  • 做内贸在哪些网站上找客户国家卫健委最新疫情报告
  • 免费开源的企业建站系统怎么用网络推广业务
  • 济南中风险地区优化好搜移动端关键词快速排名
  • 手机版网站开发实例seo什么意思简单来说
  • 乳山网站定制北京百度推广电话号码
  • 什么网站可以免费做试卷域名收录