我尝试了这个api https://github.com/facundoolano/google-play-scraper但它没有返回app的截图网址。任何人都可以为javascript建议相同的api。
答案 0 :(得分:1)
这应该有用,只需npm install request cheerio
。请注意,这是异步的,因此您可能希望将其置于承诺或类似内容中。
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);
});