|
|
@ -13,6 +13,7 @@ heroUnion.init(); |
|
|
|
|
|
|
|
|
|
|
|
const router = express.Router(); |
|
|
|
const router = express.Router(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取联盟公开接口列表
|
|
|
|
router.get('/', async (req, res) => { |
|
|
|
router.get('/', async (req, res) => { |
|
|
|
const apiList = { |
|
|
|
const apiList = { |
|
|
|
"/api/": "查看所有API", |
|
|
|
"/api/": "查看所有API", |
|
|
@ -32,6 +33,8 @@ router.get('/', async (req, res) => { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
|
|
|
|
* 联盟成员向联盟提交数据抓取任务 |
|
|
|
|
|
|
|
* |
|
|
|
* 参数列表 |
|
|
|
* 参数列表 |
|
|
|
* uuid: 用户ID |
|
|
|
* uuid: 用户ID |
|
|
|
* url: 目标网址 |
|
|
|
* url: 目标网址 |
|
|
@ -106,22 +109,45 @@ router.post('/newtask/', async (req, res) => { |
|
|
|
return res.status(200).json(data); |
|
|
|
return res.status(200).json(data); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 联盟成员向联盟查询某个任务的数据 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
**/ |
|
|
|
|
|
|
|
router.get('/querytask/', async (req, res) => { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return res.send('api/querytask/'); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* hero爬虫从联盟获取等待中的数据抓取任务 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* 参数: |
|
|
|
|
|
|
|
* platform: 爬虫支持的平台 |
|
|
|
|
|
|
|
* contract:爬虫支持的合约 |
|
|
|
|
|
|
|
* country:爬虫所在国家 |
|
|
|
|
|
|
|
* lang:爬虫支持的语言 |
|
|
|
|
|
|
|
* data_mode:爬虫支持的返回数据格式 |
|
|
|
|
|
|
|
**/ |
|
|
|
router.get('/gettask/', async (req, res) => { |
|
|
|
router.get('/gettask/', async (req, res) => { |
|
|
|
|
|
|
|
|
|
|
|
return res.send('api/gettask/'); |
|
|
|
return res.send('api/gettask/'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* hero爬虫向联盟提交某个任务的抓取结果 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
**/ |
|
|
|
router.post('/savetask/', async (req, res) => { |
|
|
|
router.post('/savetask/', async (req, res) => { |
|
|
|
|
|
|
|
//TODO: 签名检查
|
|
|
|
|
|
|
|
|
|
|
|
return res.send('api/savetask/'); |
|
|
|
//TODO: 任务状态检查,如果已经完成,则忽略当前请求
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
router.get('/querytask/', async (req, res) => { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return res.send('api/querytask/'); |
|
|
|
return res.send('api/savetask/'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
|
|
|
|
* 爬虫向联盟上报自己的状态,以保持在线 |
|
|
|
|
|
|
|
* |
|
|
|
* 参数列表 |
|
|
|
* 参数列表 |
|
|
|
* name |
|
|
|
* name |
|
|
|
* description |
|
|
|
* description |
|
|
@ -194,6 +220,7 @@ router.post('/onboard/', async (req, res) => { |
|
|
|
return res.status(200).json(data); |
|
|
|
return res.status(200).json(data); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取联盟的hero爬虫列表
|
|
|
|
router.get('/heros/', async (req, res) => { |
|
|
|
router.get('/heros/', async (req, res) => { |
|
|
|
let page = req.query.page, |
|
|
|
let page = req.query.page, |
|
|
|
limit = req.query.limit; |
|
|
|
limit = req.query.limit; |
|
|
@ -208,6 +235,7 @@ router.get('/heros/', async (req, res) => { |
|
|
|
return res.status(200).json(heroUnion.getHeros(page, limit)); |
|
|
|
return res.status(200).json(heroUnion.getHeros(page, limit)); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取联盟状态
|
|
|
|
router.get('/stats/', async (req, res) => { |
|
|
|
router.get('/stats/', async (req, res) => { |
|
|
|
return res.status(200).json(heroUnion.getStats()); |
|
|
|
return res.status(200).json(heroUnion.getStats()); |
|
|
|
}); |
|
|
|
}); |
|
|
|