-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPxtractor.py
More file actions
37 lines (33 loc) · 1.32 KB
/
Pxtractor.py
File metadata and controls
37 lines (33 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python3
# Simple proxy extractor for convinience sake
def extract_ip_port(input_file='proxies_raw.txt', output_file='proxy.txt'):
"""
Extracts IP:PORT from lines like:
46.254.93.26:80 | 6.01ms | HTTP
and writes clean 'ip:port' lines to output_file.
"""
cleaned = []
try:
with open(input_file, 'r') as f:
for line in f:
line = line.strip()
if not line:
continue
# Extract everything before the first " | "
ip_port = line.split(' | ')[0]
# Validate basic IP:PORT format
if ':' in ip_port and ip_port.replace('.', '').replace(':', '').replace(' ', '').isdigit():
cleaned.append(ip_port)
else:
print(f"[!] Skipping invalid line: {line}")
except FileNotFoundError:
print(f"[ERROR] Input file '{input_file}' not found.")
return
# Write cleaned proxies
with open(output_file, 'w') as f:
for proxy in cleaned:
f.write(proxy + '\n')
print(f"[+] Successfully extracted {len(cleaned)} proxies to '{output_file}'.")
if __name__ == "__main__":
# You can change filenames here if needed
extract_ip_port('proxies_raw.txt', 'proxy.txt')