用python3下载最新的ssr服务器地址:
2.py
import urllib.request import sys import time timetag = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) print (timetag) url = "https://github.com/Alvin9999/new-pac/wiki/ss%E5%85%8D%E8%B4%B9%E8%B4%A6%E5%8F%B7" req = urllib.request.Request(url) f = urllib.request.urlopen(req) s = f.read() s = s.decode('utf-8','ignore') #print (s) num = s.find('<p>ssr://') print (num) src = s[num:] num_end = src.find('<p><strong>') content = src[:num_end] print(content) mdir = sys.path[0]+'/' file = open(mdir+'ssr.html','a',1,'utf-8') file.write(timetag+"\n") file.write(content) file.close()
在centos服务器上,打开定时执行功能。每个小时的第一分钟执行一次。
vim /etc/crontab