adx 项目中应用 google-play-scraper bundle 爬虫

安装环境 node

wget https://nodejs.org/dist/v9.9.0/node-v9.9.0-linux-x64.tar.xz

tar xvf node-v9.9.0-linux-x64.tar.xz
ln -s /root/kairenlo/scraper/node-v9.9.0/bin/node /usr/local/bin/node
ln -s /root/kairenlo/scraper/node-v9.9.0/bin/npm /usr/local/bin/npm

Google play

https://www.npmjs.com/package/google-play-scraper

npm install google-play-scraper

App stor

https://github.com/facundoolano/app-store-scraper

npm install app-store-scraper

部署爬虫服务

web.js

//  web.js
//  引入http模块
var http = require('http')
var url  = require('url');
var gplay = require('google-play-scraper');
var store = require('app-store-scraper');

//设置请求监听函数
/**
  *  param req:   请求信息
  *  param res:   响应信息
  *  node web.js &
  */
var requestHandler = function (req, res) {
    var requset_url = req.url;
        //将字符串格式参数转化为对象使用
    var strurl  = url.parse(requset_url,true).query
    gplay.app({appId: strurl.bundle})
        .then(function(obj){
            res.end('200')
        }, function(obj){
            store.app({id:strurl.bundle})
            .then(
                function(obj){
                    res.end('200')
                }
            ).catch(
                function(err){
                    store.app({appId:strurl.bundle})
                    .then(
                        function(obj){
                            res.end('200')
                        }
                    ).catch(
                        function(err){
                            res.end('404')
                        }
                    );
                }
            );
        });
}

//创建服务器
var web = http.createServer(requestHandler)

//设置监听端口号
web.listen(7878)

console.log('http running on http://localhost:7878')

启动命令

node web.js

测试[http://localhost:7878/?bundle=553834731](http://localhost:7878/?bundle=553834731)

http://node14:7878/?bundle=com.footballstrike.soccergame