我正在制作一个下载 snapchat 故事的程序。和这个:
base64.b64decode(snap['media_iv']))
收到错误Error: Incorrect padding
实际的 media_iv 是:GhcakENDGbTNY6GzE1AV3w==
from __future__ import print_function
import os.path
import sys
from getpass import getpass
import base64
from pprint import pprint
from docopt import docopt
from Tkinter import *
from pysnap import get_file_extension, Snapchat
def printsnaps():
s = Snapchat()
s.login(u.get(), p.get())
for snap in s.get_friend_stories():
pprint(snap)
path = snap["id"]
data = s.get_story_blob(snap['media_id'],
base64.b64decode(snap['media_key']),
base64.b64decode(snap['media_iv']))
if data is None:
continue
with (openpath, 'wb') as f:
f.write(data)
top = Tk()
u = StringVar()
p = StringVar()
user = Entry(top, text="usermame", textvariable=u)
user.pack()
pswd = Entry(top, text="password", textvariable=p)
pswd.pack()
logb = Button(top, text="login", width = 15, command=printsnaps)
logb.pack()
top.mainloop()
解决方案:教程错误,不需要解码