From d22e1b5ba68f8696d8c529077a9f445a7182111b Mon Sep 17 00:00:00 2001 From: master Date: Tue, 19 Mar 2024 18:54:07 +0800 Subject: [PATCH] document update --- README.md | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++- heroUnion.mjs | 7 +++++-- 2 files changed, 60 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 951d673..03b950e 100644 --- a/README.md +++ b/README.md @@ -66,11 +66,21 @@ https://herounion.filesite.io/api/newtask/ * 请求方法:**POST** * 请求参数: ``` +uuid url +platform +data_mode selectors -token +notify_url +country +lang +sign ``` +参数说明: +* platform: url所属平台,目前支持的:抖音、快手、西瓜视频、bilibili +* data_mode: 返回数据格式,默认:json,可选值:json、html + ### 查询网页抓取任务结果接口 @@ -113,8 +123,11 @@ https://herounion.filesite.io/api/onboard/ * 请求参数: ``` bot_name +bot_description status: [idle, busy] timestamp +country +lang ``` @@ -128,6 +141,47 @@ https://herounion.filesite.io/api/stats/ * 请求参数:**无** +## 接口参数签名方法 + +将所有参数按字母排序之后拼接成GET请求字符串,最后再拼接上token计算MD5值。 + +示例如下: +``` +var token = 'hello world'; //注册联盟后获得的密钥 +var params = { //参数示例 + "b": 2, + "a": 1, + "t": 234343 +}; + +var sortObj = function(obj) { //参数排序方法 + return Object.keys(obj).sort().reduce(function (result, key) { + result[key] = obj[key]; + return result; + }, {}); +}; + +var joinObj = function(obj, glue, separator) { //参数拼接方法 + if (typeof(glue) == 'undefined') { + glue = '='; + } + + if (typeof(separator) == 'undefined') { + separator = '&'; + } + + return Object.keys(obj).map(function(key) { + return [key, obj[key]].join(glue); + }).join(separator); +}; + +//1. 排序参数 +var sortedParams = sortObj(params); +//2. 计算MD5值 +var sign = md5( joinObj(sortedParams, '=', '&') + token ); +``` + + ## Hero Union 英雄联盟开发进度 更新日期:2023-11-05 diff --git a/heroUnion.mjs b/heroUnion.mjs index f1978e0..3af0b38 100644 --- a/heroUnion.mjs +++ b/heroUnion.mjs @@ -31,7 +31,10 @@ class HeroUnion { this.task_data_max_size = 1024; //任务数据最大字节数,单位:KB this.stats = {}; - this.tasks = []; + + this.heros = []; //hero爬虫队列 + this.tasks = []; //任务队列 + this.taskStatus = { 'total': 0, 'waiting': 0, @@ -89,7 +92,7 @@ class HeroUnion { * lang: '', * url: '', * platform: '', - * data_mode: '', + * data_mode: '', //json, html * notify_url: '', * results: [], * created: 0, //timestamp in seconds