Comments (2)
The challenge thing has problems since longer time which haven't been solved. Same thing as in #1787 or #2027.
You can grab the session from your browser as descibed in #1787 or use the parameter --load-cookies
(requires preview version 4.11) and (re-)use saved sessionfile with instaloader.
from instaloader.
Based on the #1787 script, I write a new script to import hand-made cookies and it works.
First, use Chrome or Firefox to login and use developer tools to find out your cookies (or copy as HAR to find out cookies).
Then, write them into a txt file "cookies.txt" with JSON format. e,g.,
[
{
"name": "dpr",
"value": "1.31243",
"path": "/",
"domain": ".instagram.com",
"expires": "2024-03-02T03:41:01.000Z",
"httpOnly": false,
"secure": true,
"sameSite": "None"
},
{
"name": "mid",
"value": "xxxxxxxxxx3UmPXDZxxxxxxH3K",
"path": "/",
"domain": ".instagram.com",
"expires": "2025-03-30T03:40:37.752Z",
"httpOnly": false,
"secure": true
}
]
The use this script to import it automatically. You can modify the cookie parsing part to support other formats you like:
from argparse import ArgumentParser
from glob import glob
from os.path import expanduser
from platform import system
import json
try:
from instaloader import ConnectionException, Instaloader, get_default_session_filename
except ModuleNotFoundError:
raise SystemExit("Instaloader not found.\n pip install [--user] instaloader")
def import_session():
cookie_data = {items["name"]:items["value"] for items in json.load(open("cookies.txt", "r"))}
print("Using cookies {}.".format(cookie_data))
instaloader = Instaloader(max_connection_attempts=1)
instaloader.context._session.cookies.update(cookie_data)
username = instaloader.test_login()
if not username:
raise SystemExit("Not logged in. Are you logged in successfully in Firefox?")
print("Imported session cookie for {}.".format(username))
instaloader.context.username = username
sessionfile = get_default_session_filename(username)
instaloader.save_session_to_file(sessionfile)
print("Saved session to {}.".format(sessionfile))
if __name__ == "__main__":
try:
import_session()
except (ConnectionException, OperationalError) as e:
raise SystemExit("Cookie import failed: {}".format(e))
from instaloader.
Related Issues (20)
- error 429, how to bypass the rate limit? HOT 7
- unable to fetch high quality image HOT 1
- Trying to install using pip install instaloader but error 'ERROR: Could not build wheels for instaloader, which is required to install pyproject.toml-based projects'
- Errors with fetching iphone struct in highlights and story items
- Impossible to retrieve Location info | Especially Latitude and Longitude HOT 1
- The cover image download feature downloads the wrong image HOT 1
- Location ID syntax fails with HTTP code 201
- ConnectionException: JSON Query to graphql/query: HTTP error code 401. HOT 1
- Multiple post owners HOT 1
- User agent mismatch, changed many useragents but to no avail, still the same error. HOT 5
- Get hashtag #vegan: JSON Query to explore/tags/vegan/: 404 Not Found HOT 4
- Different exit codes for different failure types HOT 4
- Add more return fields on 'get_sidecar_nodes' method HOT 1
- Error downloading IGTV files
- The procedure entry point PssQuerySnapshot could not be located in the dynamic link library KERNEL32.dll. HOT 2
- How to download 615_import_firefox_session.py
- Is it possible to download a instagram reel with audio, using instaloader? HOT 2
- Trying to load_session_from_file, but it's looking in /var/folders/...
- Unable to download videos posted by users on Reels. HOT 1
- 401 error using post.get_comments(). HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from instaloader.