Clearing Cache on Firefox doesn't absolve instagram lockout from Instaloader session

720 views Asked by At

I have been using the code below to load my firefox session to allow me to scrape instagram posts. I got locked out of one of my scraping instagram accounts and don't have access to the phone or email (they are not recoverable). Instagram says the account is lost (https://help.instagram.com/358911864194456).

I am fine with the account being lost but I can no longer access instagram through firefox, which is an issue for future scraping...

Things I have tried:

  • Clearing the cache
  • Uninstalling and reinstalling

HELP!

from glob import glob
from os.path import expanduser
from sqlite3 import connect

from instaloader import ConnectionException, Instaloader


## firefox cookie database location
FIREFOXCOOKIEFILE = glob(expanduser("C:/Users/madel\AppData/Roaming/Mozilla/Firefox/Profiles/4zse1jac.default-release/cookies.sqlite"))[0]

## only allow one attempt for session connection
instaloader = Instaloader(max_connection_attempts=1)

## get cookie id for instagram
instaloader.context._session.cookies.update(connect(FIREFOXCOOKIEFILE)
                                            .execute("SELECT name, value FROM moz_cookies "
                                                     "WHERE host='.instagram.com'"))
## check connection
try:
    username = instaloader.test_login()
    if not username:
        raise ConnectionException()
except ConnectionException:
    raise SystemExit("Cookie import failed. Are you logged in successfully in Firefox?")

instaloader.context.username = username

## save session to instaloader file for later use
instaloader.save_session_to_file()
1

There are 1 answers

0
mk2080 On

I cleared the cache, cookies, and data and it worked.