subzeroid / instagrapi

🔥 The fastest and powerful Python library for Instagram Private API 2024
https://hikerapi.com/p/bkXQlaVe
MIT License
4.38k stars 685 forks source link

[BUG] How can I resolve this Instagram phishing warning when downloading reels en masse? #807

Open ghost opened 2 years ago

ghost commented 2 years ago

Describe the bug When I download approx. more than ten videos from the API, I get a phishing warning and the code halts.

To Reproduce

from instagrapi import client

class x:
    def __init__(self):
        self.cl = Client()
        self.cl.login(username, password)
        self.link = "https://www.instagram.com/reel/CgDMtmDD5sC/?utm_source=ig_web_copy_link"
    def download_reel(self, url):
        self.cl.clip_download_by_url(self.cl.media_info(self.cl.media_pk_from_url(url)).video_url, folder=Path(r"insert full directory"))
    def download(self):
        for x in range(15):
            download_reel(self.link)

z = x()
z.download()

Traceback After around ten iterations...

instagrapi.exceptions.ChallengeUnknownStep: ChallengeResolve: Unknown step_name "delta_acknowledge_approved" for "username" in challenge resolver: {'step_name': 'delta_acknowledge_approved', 'flow_render_type': 3, 'bloks_action': 'com.instagram.challenge.navigation.take_challenge', 'nonce_code': '0iM3UZIASk', 'user_id': 2250886191, 'cni': 18283399567078192, 'challenge_context': '{"step_name": "delta_acknowledge_approved", "nonce_code": "0iM3UZIASk", "user_id": 2250886191, "cni": 18283399567078192, "is_stateless": false, "challenge_type_enum": "GENERIC_PHISHED", "present_as_modal": false}', 'challenge_type_enum_str': 'GENERIC_PHISHED', 'status': 'ok'}

Expected behavior I want to download at least 30-50 reels without getting this error.

Screenshots image

Desktop (please complete the following information):

Additional context Please respond as soon as possible, thanks!

larubiano0 commented 2 years ago

Use: from time import sleep, and wait between requests. It might be useful to read this: https://thepreviewapp.com/instagram-limits/

Try to save the session settings to avoid logging in every time you run the script. Ex:

def __init__(self):
        self._cl = Client()
        if os.path.exists(IG_CREDENTIAL_PATH):
            self._cl.load_settings(IG_CREDENTIAL_PATH)
            self._cl.login(IG_USERNAME, IG_PASSWORD)
        else:
            self._cl.login(IG_USERNAME, IG_PASSWORD)
            self._cl.dump_settings(IG_CREDENTIAL_PATH)

Also, try to take a look at the examples