mirror of
https://github.com/WMK965/965-Python-Learning-Repo.git
synced 2025-04-26 13:33:21 +00:00
Update Library for Tools
This commit is contained in:
parent
ec182019d1
commit
1cf2d29089
33
BingWallpaperCapture/main.py
Normal file
33
BingWallpaperCapture/main.py
Normal file
@ -0,0 +1,33 @@
|
||||
# Script made by 965
|
||||
import requests
|
||||
import json
|
||||
import ast
|
||||
import time
|
||||
import os
|
||||
|
||||
#Bing_24-09-07_23
|
||||
console_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
|
||||
json_url = 'https://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1'
|
||||
url_suffix = '_UHD.jpg&rf=LaDigue_UHD.jpg&pid=hp&w=3840&h=2160&rs=1&c=4'
|
||||
folder_name = 'image'
|
||||
filename = 'Bing_' + time.strftime("%Y-%m-%d_%H", time.localtime())[2:] + '.jpg'
|
||||
filename_reg = str(filename)
|
||||
|
||||
if os.path.exists(f'./{folder_name}') is False:
|
||||
os.popen('mkdir image')
|
||||
print(f'[{console_time}]Making directory <image>')
|
||||
else:
|
||||
print(f'[{console_time}]Directory exist, Downloading image...')
|
||||
try:
|
||||
response = requests.get(json_url)
|
||||
response = json.loads(response.text)
|
||||
response = str(response['images'])[1:-1]
|
||||
response = ast.literal_eval(response)
|
||||
url = json_url[:20] + response['urlbase'] + url_suffix
|
||||
except:
|
||||
print(f'[{console_time}]Url processing failure')
|
||||
try:
|
||||
open(f'./{folder_name}/{filename_reg}', 'wb').write(requests.get(url).content)
|
||||
print(f'[{console_time}]Image download successful')
|
||||
except:
|
||||
print(f'[{console_time}]Image download failure')
|
26
domain-set_generator/main.py
Normal file
26
domain-set_generator/main.py
Normal file
@ -0,0 +1,26 @@
|
||||
import os
|
||||
|
||||
|
||||
domesticlist = 'https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/ChinaMax/ChinaMax_Domain.txt'
|
||||
oversealist = 'https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/Global/Global_Domain.txt'
|
||||
|
||||
os.system(f'curl -o -k --ssl-no-revoke ./domestic-ori.txt {domesticlist}')
|
||||
os.system(f'curl -o -k --ssl-no-revoke ./oversea-ori.txt {oversealist}')
|
||||
|
||||
|
||||
def modifyconf(ori, out):
|
||||
with open(ori, 'r') as f:
|
||||
lines = f.readlines()
|
||||
f2 = open(out, 'w')
|
||||
for line in lines:
|
||||
if line[0] == '#':
|
||||
continue
|
||||
elif line[0] == '.':
|
||||
f2.write(line[1:])
|
||||
else:
|
||||
f2.write(line)
|
||||
f2.close()
|
||||
|
||||
|
||||
modifyconf('domestic-ori.txt', 'domestic_domainlist.conf')
|
||||
modifyconf('oversea-ori.txt', 'oversea_domainlist.conf')
|
@ -1,5 +1,5 @@
|
||||
# encoding utf-8
|
||||
import linecache
|
||||
import linecache2 as linecache
|
||||
import re
|
||||
import os
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user