-
Notifications
You must be signed in to change notification settings - Fork 0
/
qbfs.py
70 lines (63 loc) · 2.21 KB
/
qbfs.py
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from pygal.style import Style
import pygal
import re
import linecache
from apscheduler.schedulers.background import BlockingScheduler
scheduler = BlockingScheduler()
custom_style = Style(colors=('#9AC8E2', '#BD7D74', '#B8A6D9', '#E799B0',
'#576690', '#FC966E'))
def get_line_count(filename):
count = 0
with open(filename, 'r', encoding='utf-8') as file:
while True:
buffer = file.read(1024 * 1)
if not buffer:
break
count += buffer.count('\n')
return count
def func():
fensi, bh, cya, cyb, cyc, cyd, cye, cyg = ([] for i in range(8))
fname = 'asoulbh-h.txt'
linecache.clearcache()
line_count = get_line_count(fname)
line_count = line_count - 143
for i in range(144):
last_line = linecache.getline(fname, line_count)
fs = re.findall(r'[(](.*?)[)]', last_line, re.S)
fensi.extend(fs)
line_count += 1
for x in range(0, 288, 2):
fsbh = int(fensi[x])
bh.append(fsbh)
for y in range(0, 144, 6):
cy = bh[y:y + 6]
cya.append(cy[0])
cyb.append(cy[1])
cyc.append(cy[2])
cyd.append(cy[3])
cye.append(cy[4])
cyg.append(cy[5])
view = pygal.Line(print_values=False, style=custom_style)
# 图表名
view.title = '昨日粉丝数量时间段变化'
# 添加数据
view.x_title = '时间点(1指00:00-01:00)'
view.y_title = '关注人数'
view.x_labels = map(str, range(1, 25))
view.add('向晚', list(map(int, cya)))
view.add('贝拉', list(map(int, cyb)))
view.add('珈乐', list(map(int, cyc)))
view.add('嘉然', list(map(int, cyd)))
view.add('乃琳', list(map(int, cye)))
view.add('官号', list(map(int, cyg)))
view.render_to_file('fs.svg')
# func()
job = scheduler.add_job(func,
'cron',
hour='0',
minute='0',
second='20',
timezone='Asia/Shanghai',
misfire_grace_time=None,
coalesce=True) # 每隔5s执行一次func
scheduler.start()