Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cookies
#1
Hallo,

this code to read Cookies from FireFox runs without error, but without result. In the console it shows cookies.

import sqlite3
import os

cookies =  'c:\\users\\xxx\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\xxx.default\\cookies.sqlite'

try:
    conn = sqlite3.connect(cookies)
    c = conn.cursor()
    c.execute("select host, name, value from moz_cookies")
          
    for row in c:
        host = str(row[0])
        name = str(row[1])
        value = str(row[2])
        print (host + ': ' + name + ': ' + value)
except Exception as e:
    if 'encrypted' in str(e):
        print ('encrypted')
Thank you

regards
Reply
#2
Don't use catch all except (i.e. using general Exception).
at the moment add else part to the if in the except
except Exception as e:
    if 'encrypted' in str(e):
        print ('encrypted')
    else:
        print(e)
I guess there is some exception that you shadow and don't see it.
EDIT: yes, I get "unable to open database file"
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
@buran,

thank you, but there was no hidden exception.

I used Python 3 for Windows, of course with the correct UserName and Profile. For "places" I get access to the database.

regards
Reply
#4
Hi,

Done the same thing : with result!
Try these field names in the table : moz_cookies
'select host, expiry, creationTime, lastAccessed from moz_cookies'
The date format is epoch-time, and make sure you truncate to 10 positions to get a sensible date.
(At least that is what i found)
Paul
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Retrieving Cookies whois1230 2 2,140 Nov-21-2020, 12:01 PM
Last Post: snippsat
  Requests needs cookies for login justasug 2 18,027 Jul-27-2017, 08:38 AM
Last Post: justasug

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020