(self, gaia_id)
| 11171 | return "" |
| 11172 | |
| 11173 | def _google_maps_contrib_probe(self, gaia_id): |
| 11174 | out = { |
| 11175 | "map_url": "", |
| 11176 | "reviews_url": "", |
| 11177 | "photos_url": "", |
| 11178 | "profile_name": "", |
| 11179 | "points": [], |
| 11180 | "reviews_geo": [], |
| 11181 | "photos": [], |
| 11182 | "reviews_count": None, |
| 11183 | "photos_count": None, |
| 11184 | "capture_status": "" |
| 11185 | } |
| 11186 | if not gaia_id: |
| 11187 | return out |
| 11188 | try: |
| 11189 | safe_id = re.sub(r"[^0-9]", "", str(gaia_id)) |
| 11190 | if not safe_id: |
| 11191 | return out |
| 11192 | base_url = f"https://www.google.com/maps/contrib/{safe_id}" |
| 11193 | out["map_url"] = base_url |
| 11194 | out["reviews_url"] = f"{base_url}/reviews" |
| 11195 | out["photos_url"] = f"{base_url}/photos" |
| 11196 | headers = { |
| 11197 | "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124 Safari/537.36", |
| 11198 | "Accept-Language": "it-IT,it;q=0.9,en-US;q=0.8,en;q=0.7" |
| 11199 | } |
| 11200 | texts = [] |
| 11201 | mas_texts = [] |
| 11202 | ok_pages = 0 |
| 11203 | for url in (base_url, out["reviews_url"], out["photos_url"]): |
| 11204 | try: |
| 11205 | r = self._google_maps_get_public(url, headers) |
| 11206 | if r and r.status_code == 200 and r.text: |
| 11207 | texts.append(r.text) |
| 11208 | ok_pages += 1 |
| 11209 | except Exception: |
| 11210 | continue |
| 11211 | if not texts: |
| 11212 | out["capture_status"] = "Profilo Maps non leggibile o non pubblico" |
| 11213 | return out |
| 11214 | txt = "\n".join(texts) |
| 11215 | out["capture_status"] = f"Pagine Maps lette: {ok_pages}" |
| 11216 | |
| 11217 | mas_links = [] |
| 11218 | for raw in re.findall(r'href=["\'](/locationhistory/preview/mas\?[^"\']+)', txt): |
| 11219 | link = raw.replace("\\u003d", "=").replace("\\u0026", "&") |
| 11220 | link = html.unescape(link) |
| 11221 | if link not in mas_links: |
| 11222 | mas_links.append(link) |
| 11223 | for link in mas_links[:3]: |
| 11224 | try: |
| 11225 | full_link = "https://www.google.com" + link if link.startswith("/") else link |
| 11226 | mr = session.get(full_link, headers=headers, timeout=18) |
| 11227 | if mr.status_code == 200 and mr.text: |
| 11228 | mas_texts.append(mr.text) |
| 11229 | except Exception: |
| 11230 | continue |
no test coverage detected