-
Notifications
You must be signed in to change notification settings - Fork 5
/
test.py
21 lines (17 loc) · 654 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# -*- coding: utf-8 -*-
# Authors: Joe <[email protected]>
# Date: 2022/12/30
from urllib import request, parse
import json
YUQUE_BASE_URL = 'https://yuque.com'
if __name__ == '__main__':
headers = {'X-Auth-Token': '9AP7jcwAfl6B7Jw0P8LeVkabljzB5YForzjXDoUJ'}
url = '%s/api/v2/search?type=doc&related=true&q=%s' % (YUQUE_BASE_URL, parse.quote('非结构化'))
req = request.Request(url, headers=headers)
resp = request.urlopen(req)
if resp.getcode() == 200:
resp_data = json.loads(resp.read().decode())
total = resp_data['meta']['total']
data = resp_data['data']
print(total)
print(data)