NIGHT GAMES
NIGHT GAMES

Reputation: 1

Trying to Get the responses of a Instagram Question sticker

So here is the problem,

I want to scrap/get the responses that have been made to a Instagram's question sticker using any api or insta's graphql or any other tool(plz no selerium)in python for checking the answers.. if they are correct or not

Since I am a new dev.. here is what I have done I have tried using instagrapi, instaloader, requests to get the responses... I made the programs using ChatGPT for the scripts.. and both instagrapi and instaloader didn't work and request to some degree worked it was Able to find the accounts but wasnt Able to get the sticker responses. This the code that was made using instaloader:-

 import instaloader

# Initialize Instaloader
L = instaloader.Instaloader()

# Log in to Instagram
USERNAME = "your_username"
PASSWORD = "your_password"
L.login(USERNAME, PASSWORD)

# Get user profile
profile = instaloader.Profile.from_username(L.context, USERNAME)

# Fetch recent stories
for story in L.get_stories(userids=[profile.userid]):
    for item in story.get_items():
        print(f"Story ID: {item.mediaid}")

        # Check for question stickers (manual filtering needed)
        if item.caption:
            print(f"šŸ“© Question Sticker Found: {item.caption}")

        # Download story data (responses need manual extraction)
        L.download_storyitem(item, target="story_responses")

This is the last script that I tried before asking here :-

    import requests

# Your Instagram session ID
SESSION_ID = "your_session_id"

# Your target Instagram username
USERNAME = "_focushaven_"

# Set up headers (mimics Instagram app)
headers = {
    "User-Agent": "Instagram 219.0.0.12.117 Android (30/11; 320dpi; 720x1520; Xiaomi; Redmi Note 8; willow; qcom; en_US; 346138424)",
    "Cookie": f"sessionid={SESSION_ID}",
    "Accept": "*/*",
    "Accept-Encoding": "gzip, deflate",
    "Accept-Language": "en-US,en;q=0.9",
    "X-IG-App-ID": "936619743392459"
}

# Fetch user ID
user_info = requests.get(f"https://i.instagram.com/api/v1/users/web_profile_info/?username={USERNAME}", headers=headers)
user_data = user_info.json()

if "data" in user_data and "user" in user_data["data"]:
    user_id = user_data["data"]["user"]["id"]
    print(f"āœ… Found user ID for {USERNAME}: {user_id}")
else:
    print("āŒ Failed to get user ID.")
    exit()

# Fetch all stories
stories_response = requests.get(f"https://i.instagram.com/api/v1/feed/user/{user_id}/reel_media/", headers=headers)
stories_data = stories_response.json()

found_responses = False

if "items" in stories_data:
    for story in stories_data["items"]:
        # Check for all interactive stickers
        if "story_questions" in story:
            for question in story["story_questions"]:
                print("\nšŸ“© Question Sticker Responses from _focushaven_:")
                for response in question.get("responses", []):
                    username = response["user"]["username"]
                    text = response["text"]
                    print(f"- {username}: {text}")
                    found_responses = True
        if "story_poll" in story:
            print("\nšŸ“Š Poll Sticker Responses from _focushaven_:")
            for response in story["story_poll"].get("responses", []):
                username = response["user"]["username"]
                choice = response["text"]
                print(f"- {username}: {choice}")
                found_responses = True
        # Add more fields here if there are other interactive stickers (like sliders, quizzes, etc.)

if not found_responses:
    print("āŒ No interactive sticker responses found in _focushaven_'s stories.")

So if anyone can suggest any mathod to do it then plz help.

Upvotes: -2

Views: 63

Answers (0)

Related Questions