Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions scraper.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class GoogleMapsReviewsScraper {
}
async clickReviewsTab() {
const spinner = display.startSpinner('Opening reviews tab...');
await this.page.waitForSelector('button[aria-label*="Reviews"]', { timeout: 8000 });
await this.page.waitForSelector('button[aria-label*="Reviews"]', { timeout: 15000 });
await this.page.click('button[aria-label*="Reviews"]');
await utils.sleep(1500);
display.succeedSpinner('Reviews tab opened');
Expand Down Expand Up @@ -219,11 +219,14 @@ class GoogleMapsReviewsScraper {
const name = nameEl ? nameEl.textContent.trim() : 'Unknown';
let rating = 0;
const ratingTextEl = review.querySelector('.fzvQIb');
if (ratingTextEl) {
const ratingText = ratingTextEl.textContent.trim();
const ratingMatch = ratingText.match(/(\d+)/);
rating = ratingMatch ? parseInt(ratingMatch[1]) : 0;
const ratingEl = review.querySelector('[role="img"][aria-label*="star"]');
if (ratingEl) {
const ariaLabel = ratingEl.getAttribute('aria-label');
const match = ariaLabel.match(/(\d+)\s+star/i);
if (match) {
rating = parseInt(match[1]);
}
}
const reviewTextEl = review.querySelector('.MyEned .wiI7pd');
const text = reviewTextEl ? reviewTextEl.textContent.trim() : 'No review text';
const dateEl = review.querySelector('.DU9Pgb .xRkPPb, .rsqaWe');
Expand Down