Answer the question
In order to leave comments, you need to log in
How to save a cookie to a file in Python?
I wrote a script to save cookies to a file to work with Steam, but for some reason it writes an error:
# coding: cp1251
import pickle
import steam.webauth as wa
session = wa.requests.session()
user = wa.WebAuth('LOGIN', 'PASSWORD')
try:
with open('bcc.txt','r') as f:
cookies = wa.requests.utils.cookiejar_from_dict(pickle.load(f))
session = wa.requests.session(cookies=cookies)
user.login()
except wa.TwoFactorCodeRequired:
print 'Введите код SteamGuard'
SGCode=raw_input()
user.login(twofactor_code=SGCode)
with open('bcc.txt', 'w') as f:
pickle.dump(wa.requests.utils.dict_from_cookiejar(wa.requests.session.cookies), f)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question