|
|
@ -168,15 +168,48 @@ router.get('/querytask/', async (req, res) => { |
|
|
|
* hero爬虫从联盟获取等待中的数据抓取任务 |
|
|
|
* hero爬虫从联盟获取等待中的数据抓取任务 |
|
|
|
* |
|
|
|
* |
|
|
|
* 参数: |
|
|
|
* 参数: |
|
|
|
* platform: 爬虫支持的平台 |
|
|
|
* platforms: 爬虫支持的平台 |
|
|
|
* contract:爬虫支持的合约 |
|
|
|
* contracts: 爬虫支持的合约 |
|
|
|
* country:爬虫所在国家 |
|
|
|
* country: 爬虫所在国家 |
|
|
|
* lang:爬虫支持的语言 |
|
|
|
* lang: 爬虫支持的语言 |
|
|
|
* data_mode:爬虫支持的返回数据格式 |
|
|
|
* data_mode: 爬虫支持的返回数据格式 |
|
|
|
**/ |
|
|
|
**/ |
|
|
|
router.get('/gettask/', async (req, res) => { |
|
|
|
router.get('/gettask/', async (req, res) => { |
|
|
|
|
|
|
|
let platforms = req.query.platforms, |
|
|
|
|
|
|
|
contracts = req.query.contracts, |
|
|
|
|
|
|
|
country = req.query.country ? req.query.country : 'cn', |
|
|
|
|
|
|
|
lang = req.query.lang ? req.query.lang : 'zh', |
|
|
|
|
|
|
|
data_mode = req.query.data_mode ? req.query.data_mode : 'json'; |
|
|
|
|
|
|
|
|
|
|
|
return res.send('api/gettask/'); |
|
|
|
let data = {code: 0, message: ''}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//参数检查
|
|
|
|
|
|
|
|
if (!platforms || !contracts) { |
|
|
|
|
|
|
|
data.message = '必选参数platforms、contracts不能为空'; |
|
|
|
|
|
|
|
}else if (common.isPlatformsOk(platforms) == false) { |
|
|
|
|
|
|
|
data.message = '支持的平台platforms应为英文逗号间隔的3 - 100个英文字符串'; |
|
|
|
|
|
|
|
}else if (common.isContractsOk(contracts) == false) { |
|
|
|
|
|
|
|
data.message = '支持的合约contracts应为英文逗号间隔的3 - 100个英文字符串'; |
|
|
|
|
|
|
|
}else if (country && common.isIosCountryCode(country) == false) { |
|
|
|
|
|
|
|
data.message = '国家代码country请传小写的两位字母,参考两位ISO CODES:https://countrycode.org/'; |
|
|
|
|
|
|
|
}else if (lang && common.isIosLangCode(lang) == false) { |
|
|
|
|
|
|
|
data.message = '语言代码lang请传小写的两位字母,参考ISO 639-1 Code:https://www.loc.gov/standards/iso639-2/php/code_list.php'; |
|
|
|
|
|
|
|
}else if (data_mode && data_mode != 'json' && data_mode != 'html') { |
|
|
|
|
|
|
|
data.message = '数据格式data_mode可选值:json, html'; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取等待中的任务
|
|
|
|
|
|
|
|
if (!data.message) { |
|
|
|
|
|
|
|
data.task = heroUnion.getWaitingTask(platforms, contracts, country, lang, data_mode); |
|
|
|
|
|
|
|
if (data.task) { |
|
|
|
|
|
|
|
data.code = 1; |
|
|
|
|
|
|
|
data.message = '获取待处理任务完成'; |
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
|
|
data.message = '暂时没有跟你支持的平台、合约匹配的待处理任务'; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return res.status(200).json(data); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|