Skip to content

Commit aaf06d6

Browse files
author
erkanrzgc
committed
update
1 parent edce2a0 commit aaf06d6

2 files changed

Lines changed: 25 additions & 4 deletions

File tree

core/cli.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,12 +276,33 @@ async def _verify_all_matches(result: ScanResult) -> ScanResult:
276276

277277

278278
async def _ai_verify_page(analyzer, target_username: str, full_name: str | None, known_emails: list[str], known_handles: list[str], platform: str, url: str, html: str) -> bool:
279-
"""Ask AI: is this page a real profile?"""
279+
"""Ask AI: is this page a real profile?
280+
281+
Extracts clean readable text from HTML via trafilatura (handles React/Vue/Angular/Svelte
282+
SPAs as long as the HTML is server-rendered or we pre-rendered with Playwright).
283+
Falls back to regex tag-stripping if trafilatura is not installed.
284+
"""
280285
import re
281286
from core.analysis.skill_loader import run_skill, SkillError
282287

283-
text = re.sub(r"<[^>]+>", " ", html)
284-
text = re.sub(r"\s+", " ", text).strip()[:4000]
288+
try:
289+
import trafilatura
290+
text = trafilatura.extract(
291+
html,
292+
output_format="txt",
293+
include_comments=False,
294+
include_tables=False,
295+
include_images=False,
296+
include_links=False,
297+
)
298+
if not text:
299+
text = re.sub(r"<[^>]+>", " ", html)
300+
text = re.sub(r"\s+", " ", text).strip()
301+
except ImportError:
302+
text = re.sub(r"<[^>]+>", " ", html)
303+
text = re.sub(r"\s+", " ", text).strip()
304+
305+
text = text.strip()[:4000]
285306

286307
target_ctx: dict = {"username": target_username}
287308
if full_name:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ ghunt = ["ghunt>=2.3.0", "httpx>=0.24.0"]
4242
toutatis = ["toutatis>=1.4"]
4343
phone = ["phonenumbers>=8.13"]
4444
tor = ["stem>=1.8.2"]
45-
browser = ["playwright>=1.40.0"]
45+
browser = ["playwright>=1.40.0", "trafilatura>=1.12.0"]
4646
filetype = ["magika>=0.6.0"]
4747
ai = [
4848
"llama-cpp-python>=0.3.0",

0 commit comments

Comments
 (0)