从 google play store 获取应用程序的屏幕截图
Fetch the screenshots of app from google play store
我试过这个 api https://github.com/facundoolano/google-play-scraper 但它没有 return app.Can 的屏幕截图 url 任何人都建议相同 api javascript.
这应该可以,只是 npm install request cheerio
。请注意,这是异步的,因此您可能希望将其放入 promise 或类似的内容中。
var cheerio = require("cheerio");
var request = require("request");
var baseUrl = "https://play.google.com/store/apps/details?id=";
var app = "com.spotify.music";
function getScreenShots(html) {
var $ = cheerio.load(html);
var $img = $(".thumbnails img.screenshot");
var images = [];
$img.each(function() {
images.push($(this).attr("src"));
});
console.log(images);
}
function getReviews(html) {
var $ = cheerio.load(html);
var $allReviews = $(".single-review");
var reviews = [];
$allReviews.each(function() {
var rating = $(".review-info-star-rating > div", $(this)).attr("aria-label");
var review = {
"author": $(".author-name", $(this)).text(),
"date": $(".review-date", $(this)).text(),
"rating": rating.match(/([12345]){1}/)[0] + "/5",
"comment": $(".review-body", $(this)).text()
}
reviews.push(review);
});
console.log(reviews);
}
request(baseUrl + app, function(error, response, body) {
getScreenShots(body);
getReviews(body);
});
我试过这个 api https://github.com/facundoolano/google-play-scraper 但它没有 return app.Can 的屏幕截图 url 任何人都建议相同 api javascript.
这应该可以,只是 npm install request cheerio
。请注意,这是异步的,因此您可能希望将其放入 promise 或类似的内容中。
var cheerio = require("cheerio");
var request = require("request");
var baseUrl = "https://play.google.com/store/apps/details?id=";
var app = "com.spotify.music";
function getScreenShots(html) {
var $ = cheerio.load(html);
var $img = $(".thumbnails img.screenshot");
var images = [];
$img.each(function() {
images.push($(this).attr("src"));
});
console.log(images);
}
function getReviews(html) {
var $ = cheerio.load(html);
var $allReviews = $(".single-review");
var reviews = [];
$allReviews.each(function() {
var rating = $(".review-info-star-rating > div", $(this)).attr("aria-label");
var review = {
"author": $(".author-name", $(this)).text(),
"date": $(".review-date", $(this)).text(),
"rating": rating.match(/([12345]){1}/)[0] + "/5",
"comment": $(".review-body", $(this)).text()
}
reviews.push(review);
});
console.log(reviews);
}
request(baseUrl + app, function(error, response, body) {
getScreenShots(body);
getReviews(body);
});