This commit is contained in:
@@ -85,8 +85,9 @@ function parseProducts(html: string, maxResults: number): AmazonProduct[] {
|
||||
}
|
||||
|
||||
// Extract rating: <span class="a-icon-alt">5つ星のうち4.5</span>
|
||||
const ratingMatch = block.match(/<span class="a-icon-alt">([\d.]+つ星のうち[\d.]+)<\/span>/i)
|
||||
|| block.match(/(\d+(?:\.\d+)?)\s*つ星のうち/i);
|
||||
// The actual rating is the number AFTER のうち; the one before is the scale.
|
||||
const ratingMatch = block.match(/<span class="a-icon-alt">[\d.]+つ星のうち([\d.]+)<\/span>/i)
|
||||
|| block.match(/つ星のうち\s*(\d+(?:\.\d+)?)/i);
|
||||
if (ratingMatch) {
|
||||
const rVal = ratingMatch[1].match(/(\d+(?:\.\d+)?)/);
|
||||
if (rVal) product.rating = rVal[1];
|
||||
|
||||
Reference in New Issue
Block a user