-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfun.py
41 lines (35 loc) · 1.1 KB
/
fun.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
import requests
import json
class Ds:
def __init__(self):
self.__doc__ = '返回搜索框默认内容'
self.burl = 'https://api.bilibili.com/x/web-interface/search/default'
self.ds_json = json.loads(requests.get(self.burl).text)
self.dstypenum = self.ds_json['data']['goto_type']
def showname(self):
'''
返回搜索框内容 str
'''
return self.ds_json['data']['show_name']
def dstype(self):
'''
返回指向页面类型 1为视频 int
'''
return self.dstypenum
def value(self):
'''
判断类型并给出值
如果为视频: ['video',aid] || aid->int
如果为其他: ['other',...]
'''
if self.dstypenum == 1:
return ['video',int(self.ds_json['data']['goto_value'])]
else:
return ['other',self.ds_json['data']['goto_value']]
def url(self):
'''
返回指向url
'''
return self.ds_json['data']['url']
def all(self):
return self.ds_json