Skip to content
This repository was archived by the owner on Dec 12, 2021. It is now read-only.

Commit b3f3933

Browse files
committed
Initialization
0 parents  commit b3f3933

23 files changed

+888
-0
lines changed

MMT图片爬取.py

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import os
2+
import requests
3+
4+
path="C:\\Users\\李瑞豪\\Desktop\\MMT_images\\" #下载路径: 绝对或者相对路径比如./image/
5+
os.makedirs(path+"0\\", exist_ok=True) # 创建文件夹
6+
os.makedirs(path+"1\\", exist_ok=True)
7+
8+
# 下载图片
9+
def urllib_download(url,num): # (下载链接,图片编号)
10+
from urllib.request import urlretrieve
11+
urlretrieve(url,path+num+".png")
12+
13+
# 判断状态码
14+
def get_status(url):
15+
r = requests.get(url, allow_redirects = False)
16+
return r.status_code
17+
18+
def main():
19+
BASE_URL = "https://image.xiezixiansheng.com/users/2010/700/unzip/579767/"
20+
n=33
21+
total=0
22+
print("正在爬取第1张图片!")
23+
24+
while n < 65510:
25+
#分段爬取,不然会超时!!!# 33 ~ 126 # 8212 ~ 8243 # 12289 ~ 12305 # 19968 ~ 40864 # 65281 ~ 65509
26+
if n == 127:
27+
n = 8212
28+
continue
29+
elif n == 8244:
30+
n = 12289
31+
continue
32+
elif n ==12306:
33+
n = 19968
34+
continue
35+
elif n == 40865:
36+
n = 65281
37+
continue
38+
39+
# for n in range(37341,40865):
40+
num = str(n)
41+
IMAGE_URL = BASE_URL+num+".png" # xxx.png是透明背景,xxx.png@50q是白色背景,分别存放在0,1文件夹 p是中小 w是小图
42+
if(get_status(IMAGE_URL)==200): # 同时下载透明和白色背景的图片
43+
total+=1
44+
urllib_download(IMAGE_URL,"0\\"+num)
45+
IMAGE_URL += "@50q"
46+
urllib_download(IMAGE_URL,"1\\"+num)
47+
print("Downloaded "+num+".png")
48+
print("正在爬取第",total+1,"张图片!")
49+
n+=1
50+
51+
print("\n爬取完毕!共爬取",total,"张图片!")
52+
print("图片存放路径:"+path)
53+
print("作者博客:lruihao.cn")
54+
55+
if __name__=="__main__":
56+
main();

TempConvert.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#e1.1TempConvert.py
2+
TempStr = input("请输入带有符号的温度值: ")
3+
if TempStr[-1] in ['F','f']:
4+
C = (eval(TempStr[0:-1]) - 32)/1.8
5+
print("转换后的温度是{:.2f}C".format(C))
6+
elif TempStr[-1] in ['C','c']:
7+
F = 1.8*eval(TempStr[0:-1]) + 32
8+
print("转换后的温度是{:.2f}F".format(F))
9+
else:
10+
print("输入格式错误")

csdn_visiter.zip

5.01 MB
Binary file not shown.

qrcode.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from MyQR import myqr
2+
import os
3+
version, level, qr_name = myqr.run(
4+
words='https://lruihao.cn',
5+
version=1,
6+
level='H',
7+
picture='2.jpg',
8+
colorized=True,
9+
contrast=1.0,
10+
brightness=1.0,
11+
save_name=None,
12+
save_dir=os.getcwd()
13+
)
14+
15+
# help(myqr)
16+
# https://github.com/sylnsfar/qrcode/
17+
'''
18+
Positional parameter
19+
words: str # 链接或者文字
20+
21+
Optional parameters
22+
version: int, from 1 to 40 # 控制边长
23+
level: str, just one of ('L','M','Q','H') # 控制纠错水平,从左到右依次升高。
24+
picutre: str, a filename of a image # 图片,需在同路径,默认None
25+
colorized: bool # 是否彩色 默认False
26+
constrast: float # 对比度 默认1.0
27+
brightness: float # 亮度 默认1.0
28+
save_name: str, the output filename like 'example.png' #控制文件名,默认None,'qrcode.png'
29+
save_dir: str, the output directory # 储存路径
30+
'''

settime.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import time
2+
while True:
3+
now_hour = time.strftime("%H", time.localtime())
4+
now_min = time.strftime("%M", time.localtime())
5+
if now_hour < "08":
6+
rest = 8 - int(now_hour)
7+
sleeptime = (rest-1)*3600 + (60-int(now_min))*60
8+
print("启动时北京时间为:"+time.strftime("%H:%M", time.localtime()),"\t软件将在",rest-1,"小时",int((sleeptime-(rest-1)*3600)/60),"分钟后发送数据")
9+
time.sleep(sleeptime)
10+
elif now_hour > "08":
11+
rest = 8 - int(now_hour) + 24
12+
sleeptime = (rest-1)*3600 + (60-int(now_min))*60
13+
print("启动时北京时间为:"+time.strftime("%H:%M", time.localtime()),"\t软件将在",rest-1,"小时",int((sleeptime-(rest-1)*3600)/60),"分钟后发送数据")
14+
time.sleep(sleeptime)
15+
elif now_hour == "08":
16+
print("启动时北京时间为:" + time.strftime("%H:%M", time.localtime()), "\t软件将在每天8点发送数据!")
17+
# 以下为定时任务
18+
print("数据")
19+
time.sleep(86400-int(now_min)*60)

wx回复demo.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# 导入模块
2+
from wxpy import *
3+
# 初始化机器人,扫码登陆
4+
bot = Bot()
5+
6+
my_friend = bot.friends().search('lrh')[0]
7+
my_friend.send('Hello WeChat!')

微信地区分布/city.html

+228
Large diffs are not rendered by default.

微信地区分布/wxpy.pkl

142 KB
Binary file not shown.
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from wxpy import *
2+
from pyecharts import Map
3+
4+
#因为获取的列表城市都没有带市字,而pyecharts需要带个市字
5+
b = '市'
6+
def s(x):
7+
return x+b
8+
9+
#只提取湖南的
10+
bot = Bot(cache_path = True)
11+
friends = bot.friends(update=False).search(province = '湖南')
12+
citys = []
13+
for f in friends :
14+
city = f.city
15+
citys.append(city)
16+
r = map(s,citys)
17+
cityss = list(r)
18+
19+
#为城市计数
20+
a = {}
21+
for i in cityss:
22+
a[i] = cityss.count(i)
23+
# a.pop('市')
24+
25+
#把字典进行有序拆分为2个列表
26+
attrs = []
27+
values = []
28+
for value, attr in a.items():
29+
values.append(attr)
30+
attrs.append(value)
31+
#开始绘图
32+
map = Map("湖南地图示例", width=1200, height=600)
33+
map.add("", attrs, values, maptype='湖南', is_visualmap=True, visual_text_color='#000')
34+
map.render("city.html")
10.7 MB
Binary file not shown.

微信好友墙/微信好友墙.py

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
from wxpy import *
2+
import math
3+
import PIL.Image as Image
4+
import os
5+
import sys
6+
import shutil
7+
#
8+
## 获取文件所在的绝对路径
9+
def get_dir(sys_arg):
10+
sys_arg = sys_arg.split("/")
11+
12+
dir_str = ""
13+
count = 0
14+
for cur_dir in sys_arg:
15+
if count == 0:
16+
count = count + 1
17+
if count == len(sys_arg):
18+
break
19+
dir_str = dir_str + cur_dir + "/"
20+
count = count + 1
21+
return dir_str
22+
23+
curr_dir = get_dir(sys.argv[0])
24+
25+
bot = Bot()
26+
27+
# 机器人账号自身
28+
myself = bot.self
29+
my_friends = bot.friends(update=True)
30+
31+
if not os.path.exists(curr_dir + "group-images/"):
32+
os.mkdir(curr_dir + "group-images/")
33+
34+
count = 0
35+
for friend in my_friends:
36+
print(friend.nick_name)
37+
friend.get_avatar(curr_dir + "group-images/" + str(count) + ".jpg")
38+
count = count + 1
39+
40+
# 获取下载的头像文件
41+
ls = os.listdir(curr_dir + 'group-images')
42+
43+
# 去除非 .jpg 文件
44+
for filter_ls in ls:
45+
if ".jpg" in filter_ls:
46+
continue
47+
else:
48+
ls.remove(filter_ls)
49+
50+
# 排序
51+
ls.sort(key=lambda x:int(x[:-4]))
52+
53+
# 头像墙尺寸
54+
image_size = 2560
55+
56+
each_size = math.floor(image_size/math.floor(math.sqrt(len(ls))))
57+
x_lines = math.ceil(math.sqrt(len(ls)))
58+
y_lines = math.ceil(math.sqrt(len(ls)))
59+
image = Image.new('RGB', (each_size * x_lines, each_size * y_lines))
60+
61+
x = 0
62+
y = 0
63+
64+
for file_names in ls:
65+
try:
66+
img = Image.open(curr_dir + "group-images/" + file_names)
67+
print("正在处理" + file_names.split('.jpg')[0] + "/" + str(len(ls)))
68+
except IOError:
69+
continue
70+
else:
71+
img = img.resize((each_size, each_size))
72+
image.paste(img, (x * each_size, y * each_size))
73+
x += 1
74+
if x == x_lines:
75+
x = 0
76+
y += 1
77+
78+
img = image.save(curr_dir + "all.jpg")
79+
80+
81+
try:
82+
shutil.rmtree(curr_dir + "group-images/")
83+
print("收尾,清理临时文件")
84+
except FileNotFoundError:
85+
print("没什么好删的")
86+
87+
print("!!!\n生成完毕了,放在了目录" + curr_dir + ",去看看吧。")
88+
print("工具作者:@Sunbelife(新浪微博)")
89+
print("公众号:Sunbelife")
90+
print("感谢使用")
91+
print("v1.2")
92+
print("2019.4.18")

微信男女比例.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from wxpy import *
2+
from pyecharts import Pie
3+
4+
bot = Bot(cache_path = True) #定义一个微信机器人
5+
friends = bot.friends(update=False) #获取更新好友列表
6+
male = female = other = 0
7+
8+
for i in friends[1:]: #[1:]是因为整个好友列表里面自己市在第一个,排除掉
9+
sex = i.sex
10+
if sex == 1:
11+
male += 1
12+
elif sex == 2:
13+
female += 1
14+
else:
15+
other += 1
16+
total = len(friends[1:]) #计算总数
17+
18+
#下面为分析
19+
attr = ["男性","女性","其他"]
20+
v1 = [float(male),float(female),float(other)]
21+
pie = Pie("饼图-圆环图示例", title_pos='center')
22+
pie.add("", attr, v1, radius=[40, 75], label_text_color=None, is_label_show=True,
23+
legend_orient='vertical', legend_pos='left')
24+
pie.render("sex.html")

接口测试及数据发送.py

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/usr/bin/python
2+
import requests
3+
import json
4+
import time
5+
from wxpy import *
6+
7+
# 基本信息填写:
8+
# 酒店id,酒店名称及群名列表数据,格式:["xxx","xxx","xxx"]
9+
# 使用时请将以下三个列表一一对应
10+
hotel=["xxxx","xxxx"] # 酒店后台数据接口二级域名,已匿名
11+
hotel_name=["增城宾馆","百丽酒店"]
12+
grouplist = ["麻小","富强民主文明和谐自由平等公正法治"] # "东营百丽-麻小合作群"
13+
14+
# post请求发送的数据
15+
postData = {
16+
# 'username':'test',
17+
# 'password':'123456',
18+
}
19+
20+
def get_data():
21+
result = [] #结果列表
22+
i = 0 #计数器
23+
for each in hotel:
24+
url="http://"+each+".maxiaokeji.com/xxx/xxxxxxx/xxx" # 为保护隐私及权益,这里不提供接口
25+
r = requests.post(url,data=postData)
26+
# print(r.text)
27+
28+
# 把结果转化为json字符串
29+
response=json.dumps(r.json(),indent=4,ensure_ascii=False) #sort_keys=True
30+
31+
# 把json转换为dict字典作为中间结果,再取出昨日数据
32+
midresult=json.loads(response)
33+
result.append("早上好!"+hotel_name[i]+"小程序昨日数据如下:\n访问数:"+str(midresult["data"]["yesterday_data"]["type1"])+"\n房间数:"+str(midresult["data"]["yesterday_data"]["type2"])+"\n需求量:"+str(midresult["data"]["yesterday_data"]["type3"])+"\n商品点击量:"+str(midresult["data"]["yesterday_data"]["type4"]))
34+
i+=1
35+
# print(result)
36+
return result
37+
38+
def wechat_send(bot,result):
39+
# my_friend = bot.friends().search('lrh')[0]
40+
# my_friend.send(result)
41+
i = 0 # 计数器
42+
for group in grouplist:
43+
my_group = bot.groups().search(group)[0] #依次搜索每一个群名称,每次一个
44+
my_group.send(result[i])
45+
print(result[i])
46+
print("已发送至群:"+group)
47+
i+=1
48+
49+
def main(bot):
50+
# 设置最大休眠时间,防止程序长时间占用系统资源
51+
while True:
52+
now_hour = time.strftime("%H", time.localtime())
53+
now_min = time.strftime("%M", time.localtime())
54+
# 设置每天8点发送
55+
if now_hour < "08":
56+
rest = 8 - int(now_hour)
57+
sleeptime = (rest-1)*3600 + (60-int(now_min))*60
58+
print("启动时北京时间为:"+time.strftime("%H:%M", time.localtime()),"\t软件将在",rest-1,"小时",int((sleeptime-(rest-1)*3600)/60),"分钟后发送数据")
59+
time.sleep(sleeptime)
60+
elif now_hour > "08":
61+
rest = 8 - int(now_hour) + 24
62+
sleeptime = (rest-1)*3600 + (60-int(now_min))*60
63+
print("启动时北京时间为:"+time.strftime("%H:%M", time.localtime()),"\t软件将在",rest-1,"小时",int((sleeptime-(rest-1)*3600)/60),"分钟后发送数据")
64+
time.sleep(sleeptime)
65+
elif now_hour == "08":
66+
print("软件明天开始将在每天8点发送数据!")
67+
result=get_data() # 获取数据
68+
wechat_send(bot,result) # 发送数据
69+
time.sleep(86400-int(now_min)*60)
70+
71+
if __name__=="__main__":
72+
bot = Bot(cache_path=True) # 初始化机器人,扫码登陆
73+
main(bot);

机房上机系统/computer.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
上机时间:10:05:17
2+
下机时间:10:05:19
3+
上机时长(h):1 lrh剩余机时(h):22
4.95 MB
Binary file not shown.

0 commit comments

Comments
 (0)