问题描述
我想使用Google脚本为每个星级(x个5星级,y 4星级,z 3星级-评分等)。
我在this webpage (already filtered for 1 star ratings)上使用下面的脚本,但得到“未找到评级”
function getratings(url) {
var content = UrlFetchApp.fetch(url).getContentText();
var match = content.match(/<div data-hook="cr-filter-info-review-rating-count" class="a-row a-spacing-base a-size-base".*>([^<]*)<\/div>/);
return match && match [1] ? match[1] : 'No ratings found';
}
相反,如果我在同一页面上使用此其他脚本,我就能收集到评分的总数(但不仅是1星)。
function totalReviewcount(url) {
var content = UrlFetchApp.fetch(url).getContentText();
var match = content.match(/<span class="a-size-base a-color-secondary".*>([^<]*)<\/span>/);
return match && match [1] ? match[1] : 'No reviews yet';
}
有人能指出我正确的方向吗?
谢谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)