defget_cookie_from_dingtalk(host='.baidu.com'): """host筛选网址""" # cookiepath = os.environ['LOCALAPPDATA'] + r"\Google\Chrome\User Data\Default\Cookies" cookiepath = os.environ['LOCALAPPDATA'] + r"\DingTalk\Cookies" sql = "select host_key,name,encrypted_value from cookies where host_key='%s'" % host with sqlite3.connect(cookiepath) as conn: cu = conn.cursor() cu.execute('select * from cookies;') # cookies = {name: CryptUnprotectData(encrypted_value)[1].decode() for host_key, name, encrypted_value in # cu.execute(sql).fetchall()} # print(cookies) # return cookies print(cu.fetchall())
if __name__ == '__main__': get_cookie_from_dingtalk()