代理IP用久了需要换,手动太麻烦。用Python写个自动化脚本。
import requests, time, subprocess
API_URL = "https://平台API/提取IP"
CONFIG_FILE = "proxy_config.txt"
def get_new_ip():
resp = requests.get(API_URL).json()
return resp['ip'], resp['port']
def update_config(ip, port):
with open(CONFIG_FILE, 'w') as f:
f.write(f"{ip}:{port}")
def restart_proxy():
subprocess.run(["taskkill", "/F", "/IM", "proxifier.exe"])
time.sleep(3)
subprocess.Popen(["proxifier.exe"])
while True:
ip, port = get_new_ip()
update_config(ip, port)
restart_proxy()
time.sleep(3600 * 6) # 每6小时换一次
天行IP邀请码blsj月付6元多节点配合API自动化脚本。
免责声明:代码仅供学习。






