instaloader / instaloader

Download pictures (or videos) along with their captions and other metadata from Instagram.
https://instaloader.github.io/
MIT License
8.1k stars 1.11k forks source link

I can't retrieve the total number of posts #2278

Open Plaoo opened 1 month ago

Plaoo commented 1 month ago

The bug Without login, if I try to retrieve the total number of posts for an account, it returns a redirect message: HTTP redirect from https://i.instagram.com/api/v1/users/web_profile_info/?username=cristiano https://i.instagram.com/accounts/login/?next=/api/v1/users/web_profile_info/

To Reproduce

def get_total_posts(target, total_posts):
    client = instaloader.Instaloader()

    try:
        profile = instaloader.Profile.from_username(client.context, target)
        if profile.mediacount == total_posts:
            return False

        return {"total_posts": profile.mediacount}
    except Exception as e:
        log.error(f"Error: {e}")

Expected behavior I hope to receive a number

Instaloader version 4.11

TheSnowGuru commented 4 weeks ago

this solution works well