-- coding: utf-8 --

导入正则模块

import re

定义提取IP函数

def extract_ip(file_path): # 打开urls.txt with open(file_path, 'r') as f: # 读取文本内容 content = f.read() # 提取IP ips = re.findall(r'\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}', content) return ips

调用函数

file_path = 'urls.txt' ips = extract_ip(file_path) print(ips)

Python脚本:从urls.txt文件提取IP地址

原文地址: https://www.cveoy.top/t/topic/lmLP 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录