|
|
@ -35,7 +35,7 @@ router.get('/', async (req, res) => { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* 联盟成员向联盟提交数据抓取任务 |
|
|
|
* 联盟成员向联盟提交数据抓取任务 |
|
|
|
* |
|
|
|
* |
|
|
|
* 参数列表 |
|
|
|
* 参数: |
|
|
|
* uuid: 用户ID |
|
|
|
* uuid: 用户ID |
|
|
|
* url: 目标网址 |
|
|
|
* url: 目标网址 |
|
|
|
* platform: 目标网址所属平台,可选值:[douyin, kuaishou, xigua, bilibili] |
|
|
|
* platform: 目标网址所属平台,可选值:[douyin, kuaishou, xigua, bilibili] |
|
|
@ -112,10 +112,56 @@ router.post('/newtask/', async (req, res) => { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* 联盟成员向联盟查询某个任务的数据 |
|
|
|
* 联盟成员向联盟查询某个任务的数据 |
|
|
|
* |
|
|
|
* |
|
|
|
|
|
|
|
* 参数: |
|
|
|
|
|
|
|
* uuid: 用户ID |
|
|
|
|
|
|
|
* task_id: 任务ID |
|
|
|
|
|
|
|
* sign: 参数签名,签名方法见README.md“接口参数签名方法” |
|
|
|
**/ |
|
|
|
**/ |
|
|
|
router.get('/querytask/', async (req, res) => { |
|
|
|
router.get('/querytask/', async (req, res) => { |
|
|
|
|
|
|
|
let uuid = req.query.uuid, |
|
|
|
|
|
|
|
task_id = req.query.task_id, |
|
|
|
|
|
|
|
sign = req.query.sign; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let data = {code: 0, message: ''}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//参数检查
|
|
|
|
|
|
|
|
if (!uuid || !task_id || !sign) { |
|
|
|
|
|
|
|
data.message = '必选参数uuid、task_id、sign不能为空'; |
|
|
|
|
|
|
|
}else if (common.isUuidOk(uuid) == false) { |
|
|
|
|
|
|
|
data.message = '参数uuid应为6-32位的英文字符串,请联系管理员获得'; |
|
|
|
|
|
|
|
}else if (common.isTaskIdOk(task_id) == false) { |
|
|
|
|
|
|
|
data.message = '任务编号task_id格式错误,请使用接口/api/newtask/返回数据里的id属性值'; |
|
|
|
|
|
|
|
}else if (common.isNormalName(sign, 32, 32) == false) { |
|
|
|
|
|
|
|
data.message = '签名sign应为32位的英文字符串'; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return res.send('api/querytask/'); |
|
|
|
//签名检查
|
|
|
|
|
|
|
|
let userToken = await heroUnion.getUserToken(uuid); |
|
|
|
|
|
|
|
if (!userToken) { |
|
|
|
|
|
|
|
data.message = `用户 ${uuid} 不存在,请检查参数uuid并确认大小写完整正确`; |
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
|
|
let paramsCheck = { |
|
|
|
|
|
|
|
uuid: uuid, |
|
|
|
|
|
|
|
task_id: task_id |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
let mySign = common.sign(paramsCheck, userToken); |
|
|
|
|
|
|
|
if (mySign.toLowerCase() != sign.toLowerCase()) { |
|
|
|
|
|
|
|
data.message = `签名 ${sign} 不匹配,请确保token正确及签名方法跟文档一致`; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!data.message) { |
|
|
|
|
|
|
|
data.task = heroUnion.getTaskById(task_id); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (data.task) { |
|
|
|
|
|
|
|
data.code = 1; |
|
|
|
|
|
|
|
data.message = '获取任务数据完成'; |
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
|
|
data.message = `找不到编号为${task_id}相关的任务数据`; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return res.status(200).json(data); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|