MCPcopy Create free account
hub / github.com/CScorza/IntelOSINT / _social_playwright_probe

Method _social_playwright_probe

IntelOSINT.py:14208–14275  ·  view source on GitHub ↗
(self, platform, username, url, base_icon=None)

Source from the content-addressed store, hash-verified

14206 return out
14207
14208 def _social_playwright_probe(self, platform, username, url, base_icon=None):
14209 base_icon = base_icon or ""
14210 try:
14211 with sync_playwright() as p:
14212 browser = p.chromium.launch(headless=True, args=["--log-level=3", "--disable-blink-features=AutomationControlled"])
14213 page = browser.new_page()
14214 page.set_extra_http_headers({"Accept-Language": "en-US,en;q=0.9"})
14215 response = page.goto(url, wait_until="domcontentloaded", timeout=18000)
14216 status_code = response.status if response else 500
14217 html = page.content() if response else ""
14218 final_url = response.url if response else url
14219 browser.close()
14220
14221 soup = BeautifulSoup(html, 'html.parser')
14222 if not soup:
14223 return None
14224
14225 info = {"Profile": final_url}
14226 title = ""
14227 og_title = soup.find("meta", property="og:title")
14228 if og_title and og_title.get("content"):
14229 title = str(og_title.get("content", "")).strip()
14230 if not title:
14231 twitter_title = soup.find("meta", attrs={"name": "twitter:title"})
14232 if twitter_title and twitter_title.get("content"):
14233 title = str(twitter_title.get("content", "")).strip()
14234 if not title and soup.title and soup.title.text:
14235 title = str(soup.title.text).strip()
14236
14237 if title:
14238 info["Nome"] = title
14239
14240 desc = ""
14241 og_desc = soup.find("meta", property="og:description")
14242 if og_desc and og_desc.get("content"):
14243 desc = str(og_desc.get("content", "")).strip()
14244 if not desc:
14245 twitter_desc = soup.find("meta", attrs={"name": "twitter:description"})
14246 if twitter_desc and twitter_desc.get("content"):
14247 desc = str(twitter_desc.get("content", "")).strip()
14248 if desc:
14249 info["Bio"] = desc[:260]
14250
14251 profile_img = ""
14252 og_img = soup.find("meta", property="og:image")
14253 if og_img and og_img.get("content"):
14254 profile_img = str(og_img.get("content", "")).strip()
14255
14256 found = bool(info.get("Nome") or info.get("Bio") or profile_img)
14257 if status_code == 404:
14258 info["Status"] = f"Non Trovato (Playwright HTTP {status_code})"
14259 found = False
14260 elif status_code in (401, 403, 429):
14261 info["Status"] = f"Accesso limitato (Playwright HTTP {status_code})"
14262 found = False
14263 elif status_code >= 500:
14264 info["Status"] = f"Errore accesso (Playwright HTTP {status_code})"
14265 found = False

Callers 4

enhanced_scraperMethod · 0.95

Calls 2

_social_resultMethod · 0.95
sync_playwrightFunction · 0.85

Tested by

no test coverage detected