我尝试了此api https://github.com/facundoolano/google-play-scraper,但它没有返回应用程序的屏幕快照网址。任何人都可以为JavaScript建议相同的api。

最佳答案

这应该可以,只要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);
});

关于javascript - 从Google Play商店获取应用的屏幕截图,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31206624/

10-11 00:02