# 输入文件,包含URL的内容 input_file1 = 'output10.txt' input_file2 = 'extracted_urls.txt' # 输出文件,用于存放提取出的不同的URL output_file = 'different_urls.txt' # 存放URL的集合 urls_set1 = set() urls_set2 = set() # 读取输入文件1中的URL with open(input_file1, 'r') as file1: for line in file1: urls_set1.add(line.strip()) # 读取输入文件2中的URL with open(input_file2, 'r') as file2: for line in file2: urls_set2.add(line.strip()) # 提取在extracted_urls.txt中独有的URL different_urls = urls_set2.difference(urls_set1) # 将提取出的不同的URL写入输出文件 with open(output_file, 'w') as output: for url in different_urls: # 每个URL单独一行 output.write(url + '\n') print("提取出的不同的URL已保存到输出文件中。")