const gplay = require("google-play-scraper");
const formatDate = require("./utils/formatDate");
const request = require("request").defaults({ encoding: null });
async function app() {
const url = "https://play.google.com/store/apps/details?id=com.tencent.mm";
const appId = new URL(url).searchParams.get("id");
const appInfo = await gplay
.app({ appId: appId, lang: "zh", country: "cn" })
.then(async (res) => {
const id = appId.replace(/\./gi, "-");
return {
subId: `app.android.${id}`,
subName: res.title,
appName: res.title,
version: res.version,
pubDate: formatDate(new Date(res.updated)).MD,
pubTime: res.updated,
descriptions: res.recentChanges || "",
size: res.size,
};
});
console.log(appInfo);
}
app();
function getImageBase64(imageUrl) {
return new Promise((resolve, reject) => {
request.get(imageUrl, function (error, response, body) {
if (!error && response.statusCode == 200) {
const data =
"data:" +
response.headers["content-type"] +
";base64," +
Buffer.from(body).toString("base64");
resolve(data);
} else {
reject(error);
}
});
});
}