{"id":22411411,"url":"https://github.com/ispique/instaloader-scripts","last_synced_at":"2025-07-31T22:30:45.280Z","repository":{"id":193745496,"uuid":"689335506","full_name":"isPique/Instaloader-Scripts","owner":"isPique","description":"Download an Entire Account's Instagram Posts, Saved Posts, Stories and Highlights with Python","archived":false,"fork":false,"pushed_at":"2024-10-12T12:23:08.000Z","size":2136,"stargazers_count":26,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-07T10:51:22.676Z","etag":null,"topics":["instagram","instagram-api","instaloader","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/isPique.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-09T13:39:36.000Z","updated_at":"2025-04-07T04:11:25.000Z","dependencies_parsed_at":"2024-05-08T23:29:10.132Z","dependency_job_id":"9330ceb3-c75b-43ec-aae4-e27e2ffee78d","html_url":"https://github.com/isPique/Instaloader-Scripts","commit_stats":null,"previous_names":["ispique/instaloader-scripts"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/isPique/Instaloader-Scripts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isPique%2FInstaloader-Scripts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isPique%2FInstaloader-Scripts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isPique%2FInstaloader-Scripts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isPique%2FInstaloader-Scripts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/isPique","download_url":"https://codeload.github.com/isPique/Instaloader-Scripts/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isPique%2FInstaloader-Scripts/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268127127,"owners_count":24200310,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-31T02:00:08.723Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["instagram","instagram-api","instaloader","python"],"created_at":"2024-12-05T13:13:55.239Z","updated_at":"2025-07-31T22:30:44.914Z","avatar_url":"https://github.com/isPique.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Instaloader Auxiliar Scripts\nHere, you'll find some scripts that download an Instagram account's posts, stories, etc.\n\n\u003e [!IMPORTANT]\n\u003e * Instaloader is constantly improving and evolving, and adapting its code to platform changes. This implies that some endpoints may change, and some of the scripts may stop working.\n\u003e * The objective of this repository is to serve as an example, it has educational purposes, and in no case does it pretend to be perfect or fully functional.\n\u003e * Please, see: [Instaloader](https://instaloader.github.io/)\n\n# INSTALLATION\n\n1. Clone the repository:\n```bash\ngit clone https://github.com/isPique/Instaloader-Scripts.git\n```\n\n2. Navigate to the project directory:\n```bash\ncd Instaloader-Scripts\n```\n\n3. Install required libraries\n```bash\npip install -r requirements.txt\n```\n\n# Usage\n\n\u003e [!WARNING]\n\u003e Please make sure you don't use a VPN before running the script, because if you do, this happens;\n\n![Action Blocked](https://github.com/isPique/Instaloader-Scripts/blob/main/images/Action%20Blocked%20-%20Error.jpeg)\n\n* Anyways. You'll need to set up a few things before running the script.\n\n* Set your own Instagram username and password on `posts.py`, `stories.py` and `highlights.py` (personal account not recommended just create a new account). If you want to download your personal account's saved posts, you can use your personal account on `saved_posts.py`.\n\n* If you get an error like `JSON Query to accounts/login/: Could not find \"window._sharedData\" in html response.` (which will happen with a 99% probability), you can login with your cookies.\n\n## How to log in with cookies?\n\n**1- Login to Instagram**: Login to Instagram in your browser with your username and password.\n\n**2- Open Developer Tools**: In most web browsers, you can access developer tools by right-clicking on a webpage and selecting \"Inspect\" or \"Inspect Element.\" Alternatively, you can press F12 or Ctrl+Shift+I to open developer tools.\n\n**3- Navigate to the Application or Storage Tab**: In the developer tools window, there should be a tab called \"Application\" or \"Storage\" (the exact name may vary depending on the browser). Click on it.\n\n**4- Expand Cookies**: In the Application or Storage tab, you'll find a section for \"Cookies\" in the left sidebar. Expand this section by clicking on it.\n\n**5- Find the Cookie for Instagram**: Look for the https://www.instagram.com/ link. Click on it to view the cookies.\n\n**6- Find the Session ID and CSRF Token**: In the list of cookies you should see one labeled \"Session ID\" or something similar. The name of the session cookie may vary depending on the website or application you are using. The value of this cookie is your session ID. Likewise, in the list of cookies, you should see one labeled \"CSRF Token\" or something similar. The value of this cookie is your CSRF (Cross-Site Request Forgery) Token.\n\n* After following all these steps you should see something like this;\n\n![Cookies](https://github.com/isPique/Instaloader-Scripts/blob/main/images/Cookies.jpg)\n\n* Set your own **username**, **password**, **Session ID**, **CSRF Token**, and the **username of the person who has the posts you want to download** in the script you intend to use and run the script. You'll see that the posts start to download in the directory where you run the script.\n\n* Additionally, when you run the script, it saves your cookies to a text file named `cookies.txt`. This means you won't need to use your credentials in subsequent runs. The script logs in with the cookie file in second and subsequent executions.\n\n# \n\n\u003e [!TIP]\n\u003e If you're using the firefox browser, you can use the code below to get the `cookies.txt` file.\n\n```py\nfrom argparse import ArgumentParser\nfrom glob import glob\nfrom os.path import expanduser\nfrom platform import system\nfrom sqlite3 import OperationalError, connect\n\ntry:\n    from instaloader import ConnectionException, Instaloader\nexcept ModuleNotFoundError:\n    raise SystemExit(\"Instaloader not found.\\n  pip install [--user] instaloader\")\n\n\ndef get_cookiefile():\n    default_cookiefile = {\n        \"Windows\": \"~/AppData/Roaming/Mozilla/Firefox/Profiles/*/cookies.sqlite\",\n        \"Darwin\": \"~/Library/Application Support/Firefox/Profiles/*/cookies.sqlite\",\n    }.get(system(), \"~/.mozilla/firefox/*/cookies.sqlite\")\n    cookiefiles = glob(expanduser(default_cookiefile))\n    if not cookiefiles:\n        raise SystemExit(\"No Firefox cookies.sqlite file found. Use -c COOKIEFILE.\")\n    return cookiefiles[0]\n\n\ndef import_session(cookiefile, sessionfile):\n    print(\"Using cookies from {}.\".format(cookiefile))\n    conn = connect(f\"file:{cookiefile}?immutable=1\", uri=True)\n    try:\n        cookie_data = conn.execute(\n            \"SELECT name, value FROM moz_cookies WHERE baseDomain='instagram.com'\"\n        )\n    except OperationalError:\n        cookie_data = conn.execute(\n            \"SELECT name, value FROM moz_cookies WHERE host LIKE '%instagram.com'\"\n        )\n    instaloader = Instaloader(max_connection_attempts=1)\n    instaloader.context._session.cookies.update(cookie_data)\n    username = instaloader.test_login()\n    if not username:\n        raise SystemExit(\"Not logged in. Are you logged in successfully in Firefox?\")\n    print(\"Imported session cookie for {}.\".format(username))\n    instaloader.context.username = username\n    instaloader.save_session_to_file(sessionfile)\n\n\nif __name__ == \"__main__\":\n    p = ArgumentParser()\n    p.add_argument(\"-c\", \"--cookiefile\")\n    p.add_argument(\"-f\", \"--sessionfile\")\n    args = p.parse_args()\n    try:\n        import_session(args.cookiefile or get_cookiefile(), args.sessionfile)\n    except (ConnectionException, OperationalError) as e:\n        raise SystemExit(\"Cookie import failed: {}\".format(e))\n```\n\n* Example usage:\n```bash\npython whatever_you_named_your_file.py --sessionfile \"path\\to\\your\\Instaloader Scripts\\cookies.txt\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fispique%2Finstaloader-scripts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fispique%2Finstaloader-scripts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fispique%2Finstaloader-scripts/lists"}