1. 分析
龍蛋領取網絡請求圖
- 自己的分享鏈接
http://t.cn/*****
,這是個短網址 - 短網址還原成長網址,並重定向到長網址
棒棒糖的長網址格式http://www.battleofballs.com/index_PC.html?id=*****&Account=*****&Channel=*****
拿到id
龍蛋的長網址格式http://www.battleofballs.com/share/index.html?b=AAAAAAAAAA------(base64編碼)
須解碼得到id - 領取地址
棒棒糖http://cn.battleofballs.com/share?type=1&id=***
龍蛋http://cn.battleofballs.com/share?type=3&id=***
2. 短網址還原
找了一個在線的api,短網址還原接口地址
代理ip
請自行百度 代理ip,有很多免費的.
- 爬取ip並存入數據庫
存入數據庫的ip,狀態默認爲0,(0:未檢測.1:可用,-1:不可用)
- 測試ip是否可用
用代理ip去訪問 球球大作戰官網或者百度
修改數據庫 狀態置爲 1 或者 -1
- 用狀態爲1 的代理ip去訪問 領取地址
定時任務
將執行代碼按順序寫到 定時任務中,每天這行並領取.
技術
實現的技術有很多,記錄下自己實現所用框架.
nodejs+koa2+mongodb
superagent+cheerio+superagent-proxy
"dependencies": {
"axios": "^0.19.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
"babel-register": "^6.26.0",
"cheerio": "^1.0.0-rc.3",//服務器端需要對DOM進行操作
"cron": "^1.7.1",//定時任務
"koa": "^2.7.0",
"koa-bodyparser": "3",//解析request的body
"koa-router": "^7.4.0",//路由
"koa2-cors": "^2.0.6",//解決跨域
"moment": "^2.24.0",//時間的插件
"mongoose": "^5.6.7",//MongoDB
"nodemon": "^1.19.1",//熱重啓
"superagent": "^5.1.0",//爬蟲
"superagent-proxy": "^2.0.0"//superagent代理
}
這只是個大致的思路,具體實現,還有許多細節需要考慮,這裏就不寫這麼多了