I want to crawl the app info based on app id (e.g. com.instagram.android) in Google Play.
I used the npm package as the crawler: https://www.npmjs.com/package/google-play-scraper
I don't have any javascript experience before, I don't know how to modify it for my purpose. For now, I cannot use that for crawling a list of app IDs, and save the returned results as a *.txt for further analysis.
I have tried their sample code, and it runs well. But I could only see the returned results by .then(console.log, console.log)
. How could I save the results to a .txt file???
var gplay = require('google-play-scraper');
gplay.app({appId: 'com.dxco.pandavszombies'})
.then(console.log, console.log);
I am stuck here, could anyone help me on this issue? I have tried many different ways to solve this problem, but they all didn't work... I am really confused about how to save the value returned to .txt file
I tried to save all the potential variables into the .txt files, only the info like:
[object]
[object promise]
are saved.
I tried to save it like this:
var first = gplay.app({appId: 'com.instagram.android'});
app_result = first.then((result) => console.log(result));
fs.writeFile('App_Result.txt', app_result, (err) =>{
if (err) throw err;
console.log('App_Result saved!');
});
I understand that this may be caused by the strategy of Promise, which I need to wait for the Promise resolved and then the results could be returned. But I don't know how to figure out it since I am really new for the javascript.