Skip to content

Fix: wrap profile_id extraction in try block to handle unexpected ava…#85

Open
GANESH9124 wants to merge 1 commit intobocchilorenzo:mainfrom
GANESH9124:main
Open

Fix: wrap profile_id extraction in try block to handle unexpected ava…#85
GANESH9124 wants to merge 1 commit intobocchilorenzo:mainfrom
GANESH9124:main

Conversation

@GANESH9124
Copy link

…tar formats

Parse avatar url to get profile_id with handled for static avatar images path, CDN paths etc.
Now, scraping wont fail due to failure of single profile_id
In _get_user function

# Extract profile_id directly from the avatar URL if available
        if "profile_images" in avatar:
            try:
                profile_id_candidate = avatar.split("/profile_images/")[1].split("/")[0]
                if profile_id_candidate.isdigit():
                    profile_id = profile_id_candidate
                else:
                    profile_id = "unknown"
                    logging.warning(f"Invalid profile id format extracted from avatar: {avatar}")
            except IndexError:
                profile_id = "unknown"
                logging.error(f"IndexError when extracting profile id from avatar: {avatar}")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants