0
我试过这个API https://github.com/facundoolano/google-play-scraper,但它不返回应用程序的截图网址。任何人都可以为javascript提供相同的API。从谷歌播放商店获取应用程序的截图
我试过这个API https://github.com/facundoolano/google-play-scraper,但它不返回应用程序的截图网址。任何人都可以为javascript提供相同的API。从谷歌播放商店获取应用程序的截图
这应该工作,只是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);
});
以同样的方式,我们可以得到用户评论? – Ankita
当然,我已经更新了我的答案以及审查示例。 – hampusohlsson