-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathob.py
61 lines (48 loc) · 2.37 KB
/
ob.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
import requests
import json
import matplotlib.pyplot as plt
import numpy as np
class Fanslook:
def __init__(self,page=5):
self.__doc__ = '数据来源:biliob.com \n 网站作者:Jannchie见齐'
self.headers = {
"User-Agent":"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.204 Safari/537.36",
}
self.burl = 'https://www.biliob.com/api/event/fans-variation?pagesize=' + str(page)
self.fjson = json.loads(requests.get(self.burl,headers=self.headers).text)
self.case = self.fjson['content']
self.fans_list = [[p["author"],p["mid"],p["variation"]] for p in self.case ]
def fans(self):
return self.fans_list
def copyright(self):
print('''
数据来源:biliob.com \n
网站作者:Jannchie见齐 \n
模块作者:Lixiaobai
''')
class Bilitime:
def __init__(self):
self.headers = {
"User-Agent":"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.204 Safari/537.36",
}
self.turl = 'https://www.biliob.com/api/site'
self.tjson = json.loads(requests.get(self.turl,headers=self.headers).text)
self.playlist = [playitem['playOnline'] for playitem in self.tjson]
self.weblist = [playitem['webOnline'] for playitem in self.tjson]
self.datelist = [playitem['datetime'] for playitem in self.tjson]
def draw(self):
plt.rcParams['font.sans-serif'] = ['KaiTi'] # 指定默认字体
plt.rcParams['axes.unicode_minus'] = False # 解决保存图像是负号'-'显示为方块的问题
plt.title("在线人数,观看数曲线")
x1 = np.array([i+1 for i in range(len(self.playlist))][::-1])
y1 = np.array(self.playlist)
plt.plot(x1,y1,color = 'dodgerblue',label = "播放人数")# 折线 1 x 2 y 3 color
x2 = np.array([i+1 for i in range(len(self.weblist))][::-1])
y2 = np.array(self.weblist)
plt.plot(x2,y2,color = 'r',label = "在线人数")# 折线 1 x 2 y 3 color
plt.show()
def zipped(self):
self.zipper =[]
for i in range(len(self.playlist)):
self.zipper.append([self.playlist[i],self.weblist[i],self.datelist[i]])
return self.zipper