Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New solution for reusing cookies #349

Open
5 of 6 tasks
321qwedsa000 opened this issue Jun 19, 2021 · 2 comments
Open
5 of 6 tasks

New solution for reusing cookies #349

321qwedsa000 opened this issue Jun 19, 2021 · 2 comments

Comments

@321qwedsa000
Copy link

321qwedsa000 commented Jun 19, 2021

Please follow the guide below

  • Issues submitted without this template format will be ignored.
  • Read the questions carefully and answer completely.
  • Do not post screenshots of error messages or code.
  • Put an x into all the boxes [ ] relevant to your issue (==> [x] no spaces).
  • Use the Preview tab to see how your issue will actually look like.
  • Issues about reverse engineering is out of scope and will be closed without response.
  • Any mention of spam-like actions or spam-related tools/libs/etc is strictly not allowed.

Before submitting an issue, make sure you have:

  • Updated to the lastest version v1.6.0
  • Read the README and docs
  • Searched the bugtracker for similar issues including closed ones
  • Reviewed the sample code in tests and examples

Which client are you using?

  • app (instagram_private_api/)
  • web (instagram_web_api/)

Describe your Feature Request:

Please make sure the description is worded well enough to be understood with as much context and examples as possible.

#simple solution for reusing cookies
from instagram_private_api import Client
import pickle
import os
#write binary file with api.settings
def writeSettings(user,pwd,settings_file):
    api = Client(user,pwd)
    with open(settings_file,"wb") as FileObj:
         pickle.dump(api.settings,FileObj)
#read binary file to api.settings
def readSettings(settings_file):
    cache = None
    with open(settings_file,"rb") as FileObj:
        cache = pickle.load(FileObj)
    return cache
if not os.path.exists("settingObj"):
    writeSettings("user","pwd","settingObj")
cache_settings = readSettings("settingObj")
api = Client("user","pwd",settings=cache_settings)
#usually  worked well
@321qwedsa000 321qwedsa000 changed the title New soution for reusing cookies New solution for reusing cookies Jun 19, 2021
@TheAverageProgrammar
Copy link

I have been looking for a solution for changing the user agent but have not been able to find one how to do it ?

@RealA10N
Copy link

Be careful, you are opening files without closing them. The best practice is to open files using the with open(...) as ... syntax,
In any case, the developer of the module intentionally left the implementation of caching the settings to the user of the library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants