From e417f565fb17d267c012eb57eaf5ced1e31a89d1 Mon Sep 17 00:00:00 2001 From: yeyin Date: Wed, 17 Dec 2025 13:27:59 +0100 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=E3=80=8Cjson=E3=80=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- json/夸克分享.json | 18 ++++++++++ json/采集转换器.py | 88 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 json/夸克分享.json create mode 100644 json/采集转换器.py diff --git a/json/夸克分享.json b/json/夸克分享.json new file mode 100644 index 0000000..2145e1f --- /dev/null +++ b/json/夸克分享.json @@ -0,0 +1,18 @@ +{ + + "classes": [ + { + "type_name": "花生十三", + "type_id": "8dd332256252" + }, + { + "type_name": "食谱", + "type_id": "78414690490e" + }, + { + "type_name": "体育", + "type_id": "25bf5b71edbb" + } + ], + "cookie":"__puus=0d26f820dbe87c2ff7689eca16d33dbdAATbA+y7U6E45kIqf3tUJD3ubw3yiLFUneh7o2z7qsn/vNtt13XnX5nq24o8c1PFNiaRXf9lCjyU8a8OHOwiWUwyB2awYMF3Q3KeegYcdEvy8ND7sRa0vlDQ1nPIWdR0BZD52AXBQj5UBIy0E2yknnBf+bzag4ivcZLepQskKRVGJ8tlB7jy8sgOem4zOP0cxKCMZLmwUeeaKFzdCnlhqj9+;__pus=69d93c40091ac35657fcdad30c901d8fAATxYe3kuhbmWR/i/UY5HxwQQPHPfx2Y/oEUXCA5LbTk2cvg8UqI6jwVZs1vlK34HoJ6KsjzHygZE3SbMoQVW2g6;__kp=c9e05ec0-8574-11ef-8fbe-77ecc2a14af3" +} diff --git a/json/采集转换器.py b/json/采集转换器.py new file mode 100644 index 0000000..dc727fa --- /dev/null +++ b/json/采集转换器.py @@ -0,0 +1,88 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# File : 采集转换器.py +# Author: DaShenHan&道长-----先苦后甜,任凭晚风拂柳颜------ +# Date : 2024/7/4 + +import json +import requests +from urllib.parse import urlsplit +from collections import OrderedDict + + +def get_host(url): + """ + 获取主页地址 + @param url: + @return: + """ + ret = urlsplit(url) + return f'{ret.scheme}://{ret.netloc}' + + +def get_sid(url): + """ + 获取id主页 + @param url: + @return: + """ + ret = urlsplit(url) + return ret.netloc + + +def get_api(url): + """ + 获取接口api + @param url: + @return: + """ + ret = urlsplit(url) + return ret.path.rstrip('/') + '/' + + +def delete_same(data, key='url'): + """ + 字典列表去重,按字典的某个key + @param data: + @param key: + @return: + """ + unique_data = list(OrderedDict((d[key], d) for d in data).values()) + if key == 'sid': + for site in unique_data: + del site['sid'] + return unique_data + + +def main(zy_url="https://cdn.jsdelivr.net/gh/waifu-project/v1@latest/zy.json"): + r = requests.get(zy_url) + ret = r.json() + sites = ret['sites']['data'] + sites = [site for site in sites if site.get('type') and site['type'] == 1] + print(f'共计发现type1的站点:{len(sites)}条记录') + covert_sites = [] + for site in sites: + if site.get("name") and site.get("api"): + surl = site['api'] + host = get_host(surl) + api = get_api(surl) + sid = get_sid(surl) + cvalue = { + "sid": sid, + "name": site["name"], + "url": host, + "parse_url": "", + "cate_exclude": "" + } + if api != '/api.php/provide/vod/': + cvalue["api"] = api + covert_sites.append(cvalue) + print(f'转换完成采集之王的站点:{len(covert_sites)}条记录') + covert_sites = delete_same(covert_sites, 'sid') + print(f'去重后的采集之王的站点:{len(covert_sites)}条记录') + with open('采集[zy].json', mode='w+', encoding='utf-8') as f: + f.write(json.dumps(covert_sites, ensure_ascii=False, indent=4)) + + +if __name__ == '__main__': + main()