refactor(instagram): improve anonymous scraping logic and error messaging

Enhanced the Instagram scraper to clarify the requirements for accessing user profiles and hashtags. Updated the error message for blocked access to provide detailed guidance on necessary credentials. Introduced a regex for validating Instagram usernames and refined the discovery function to handle profile queries directly, improving user experience and error handling in anonymous mode.
This commit is contained in:
Anish Sarkar 2026-07-09 20:23:09 +05:30
parent f66ab73044
commit 82f1d0b4e5
2 changed files with 27 additions and 42 deletions

View file

@ -43,7 +43,10 @@ def build_scrape_executor(scrape_fn: ScrapeFn | None = None) -> Executor:
except InstagramAccessBlockedError as exc:
# Anonymous-only scraper; a hard block can't be retried with creds.
raise ForbiddenError(
f"Instagram refused anonymous access: {exc}",
"Instagram requires a login for this request and SurfSense scrapes "
"anonymously. Provide a profile URL or handle via directUrls; "
"keyword/hashtag search needs an account and is unavailable. "
f"Details: {exc}",
code="INSTAGRAM_ACCESS_BLOCKED",
) from exc
emit_progress(