Fix: Add early no-reviews detection and hide analytics for empty jobs

Changes:
- Early detection for "no reviews" messages in 11 languages
- Checks for disabled reviews tabs and 0-review indicators
- Returns early (saves 30-40s) when no reviews exist
- Frontend hides analytics/export buttons when reviews_count = 0
- Structural pattern matching improvements (work in progress)

Known issue:
- Lithuanian hospital page has different structure (no tabs found)
- Needs separate investigation - may use different Google Maps layout

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Alejandro Gutiérrez
2026-01-18 20:14:04 +00:00
parent c8c24ae483
commit e98da314a5
9 changed files with 1107 additions and 0 deletions

92
test_without_english.py Normal file
View File

@@ -0,0 +1,92 @@
#!/usr/bin/env python3
"""
Test WITHOUT forcing English locale - use the page's default language.
"""
import time
from seleniumbase import Driver
# NO hl=en parameter!
url = "https://www.google.com/maps/search/?api=1&query=panevezio%20respubliikine%20ligonine"
driver = Driver(uc=True, headless=False)
try:
driver.get(url)
print(f"Loaded (NO hl=en): {url}")
time.sleep(5)
# GDPR
try:
form_btns = driver.find_elements('css selector', 'form button')
for btn in form_btns:
btn_text = (btn.text or '').lower()
if 'accept' in btn_text or 'priim' in btn_text: # Lithuanian "priimti"
print(f"Clicking consent: {btn.text}")
btn.click()
time.sleep(2)
break
except:
pass
# List ALL tabs
print("\nALL TABS FOUND:")
time.sleep(2)
tabs = driver.find_elements('css selector', 'button[role="tab"]')
for i, tab in enumerate(tabs, 1):
text = tab.text or ''
aria = tab.get_attribute('aria-label') or ''
print(f" Tab {i}: text='{text}', aria='{aria}'")
# Look for reviews tab (try multiple keywords)
review_keywords = ['review', 'reseña', 'atsiliepimai', 'atsiliepi', 'отзыв']
review_tab_found = False
for tab in tabs:
text = (tab.text or '').lower()
aria = (tab.get_attribute('aria-label') or '').lower()
for keyword in review_keywords:
if keyword in text or keyword in aria:
print(f"\nFound REVIEWS TAB: {tab.text or aria[:50]}")
driver.execute_script("arguments[0].click();", tab)
time.sleep(5)
review_tab_found = True
break
if review_tab_found:
break
if not review_tab_found:
print("\nWARNING: Still no reviews tab found!")
else:
# Now scroll and check for reviews
print("\nScrolling to load reviews...")
try:
pane = driver.find_element('css selector', 'div.m6QErb.WNBkOb.XiKgde')
for i in range(10):
driver.execute_script("arguments[0].scrollBy(0, 400);", pane)
time.sleep(0.3)
except:
pass
# Check for reviews using known selectors
selectors_to_check = [
'div.jftiEf.fontBodyMedium',
'div.jftiEf',
'div.fontBodyMedium',
'div[data-review-id]'
]
print("\nChecking selectors:")
for selector in selectors_to_check:
count = driver.execute_script(f"return document.querySelectorAll('{selector}').length;")
print(f" {selector:30} : {count} elements")
print(f"\n{'='*80}")
print("Browser open for inspection (120s)...")
print(f"{'='*80}")
time.sleep(120)
finally:
driver.quit()