Skip to content

🕵️‍♂️ (2-in-1) Email & Username OSINT suite featuring native MCP support for deep data extraction just from a single Email/Username. Analyzes 2720+ actively maintained scan vectors (210+ email / 2510+ username) for security research, investigations, and digital footprinting.

refactor(linktree): add extraction logic to extract the showcased_links

Kaif172a05cf786e
diff --git a/user_scanner/user_scan/creator/linktree.py b/user_scanner/user_scan/creator/linktree.py
index 2a88b36..7f71b2d 100644
--- a/user_scanner/user_scan/creator/linktree.py
+++ b/user_scanner/user_scan/creator/linktree.py
@@ -1,4 +1,5 @@
import re
+import json
from user_scanner.core.helpers import get_random_user_agent
from user_scanner.core.orchestrator import Result, make_request
@@ -18,22 +19,75 @@ def validate_linktree(user):
if response.status_code == 200:
html = response.text
extra = {}
- title = re.search(r'<title[^>]*>(.*?)</title>', html, re.IGNORECASE)
- if title:
- title_text = title.group(1).strip()
- if " | Linktree" in title_text:
- title_text = title_text.split(" | Linktree")[0]
- elif "| Linktree" in title_text:
- title_text = title_text.split("| Linktree")[0]
- extra["name"] = title_text.strip()
-
- desc = re.search(r'<meta[^>]*property="og:description"[^>]*content="([^"]+)"', html, re.IGNORECASE)
- if desc:
- extra["description"] = desc.group(1).strip()
-
- img = re.search(r'<meta[^>]*property="og:image"[^>]*content="([^"]+)"', html, re.IGNORECASE)
- if img:
- extra["image"] = img.group(1).strip()
+
+ # Try to parse __NEXT_DATA__ first for deep extraction
+ next_data_match = re.search(
+ r'<script[^>]*id="__NEXT_DATA__"[^>]*>(.*?)</script>', html, re.DOTALL)
+ parsed_successfully = False
+ if next_data_match:
+ try:
+ data = json.loads(next_data_match.group(1))
+ page_props = data.get('props', {}).get('pageProps', {})
+ account = page_props.get('account', {})
+
+ name = page_props.get(
+ 'pageTitle') or account.get('pageTitle')
+ if name:
+ extra['name'] = name.strip()
+
+ desc = page_props.get(
+ 'description') or account.get('description')
+ if desc:
+ extra['description'] = desc.strip()
+
+ avatar = account.get(
+ 'profilePictureUrl') or page_props.get('customAvatar')
+ if avatar:
+ extra['avatar'] = avatar.strip()
+
+ verified = page_props.get('isProfileVerified')
+ if verified is not None:
+ extra['verified'] = verified
+
+ links = page_props.get('links', [])
+ if links:
+ extra['showcased_links'] = [
+ f"{link.get('title', '').strip()}: {link.get('url', '').strip()}"
+ for link in links if link.get('url')
+ ]
+
+ social = page_props.get('socialLinks', [])
+ if social:
+ extra['social_links'] = [
+ f"{s.get('platform', '').strip()}: {s.get('url', '').strip()}"
+ for s in social if s.get('url')
+ ]
+ parsed_successfully = True
+ except Exception:
+ pass
+
+ # Fallback to metadata regex if NEXT_DATA parsing failed or was incomplete
+ if not parsed_successfully:
+ title = re.search(
+ r'<title[^>]*>(.*?)</title>', html, re.IGNORECASE)
+ if title:
+ title_text = title.group(1).strip()
+ if " | Linktree" in title_text:
+ title_text = title_text.split(" | Linktree")[0]
+ elif "| Linktree" in title_text:
+ title_text = title_text.split("| Linktree")[0]
+ extra["name"] = title_text.strip()
+
+ desc = re.search(
+ r'<meta[^>]*property="og:description"[^>]*content="([^"]+)"', html, re.IGNORECASE)
+ if desc:
+ extra["description"] = desc.group(1).strip()
+
+ img = re.search(
+ r'<meta[^>]*property="og:image"[^>]*content="([^"]+)"', html, re.IGNORECASE)
+ if img:
+ extra["image"] = img.group(1).strip()
+
return Result.taken(extra=extra, url=show_url)
elif response.status_code == 404:
return Result.available(url=show_url)