add cookie extractor only supports firefox for now
This commit is contained in:
parent
3dcba94b95
commit
ad969abfe1
@ -3,10 +3,18 @@ import requests
|
||||
from bs4 import BeautifulSoup
|
||||
from enum import Enum
|
||||
import re
|
||||
import shutil
|
||||
from dateconverter import *
|
||||
from datetime import datetime
|
||||
import os
|
||||
import sqlite3
|
||||
|
||||
DEBUG = True
|
||||
number = ['0','1','2','3','4','5','6','7','8','9']
|
||||
homePath = os.path.expanduser('~')
|
||||
cookiePath = homePath + "/.mozilla/firefox/imibizoh.default/cookies.sqlite"
|
||||
tmpPath = "/tmp/cookies.sqlite"
|
||||
DBFILE = "../db/sqlite3.db"
|
||||
def log(*s):
|
||||
if DEBUG:
|
||||
print(s)
|
||||
@ -208,8 +216,33 @@ def indeedExtractDays(datestr):
|
||||
cleannumstr+=a
|
||||
elif a not in number and foundchar == True:
|
||||
break
|
||||
cleannumint = int(cleannumstr)
|
||||
today = int(datetime.utcnow().timestamp())
|
||||
cleandate = today - cleannumint * 60 * 60 * 7 * 4
|
||||
if cleannumstr != '':
|
||||
cleannumint = int(cleannumstr)
|
||||
today = int(datetime.utcnow().timestamp())
|
||||
cleandate = today - cleannumint * 60 * 60 * 7 * 4
|
||||
#print("int:",cleannumint,"today:",today,"cleandate:",datetime.fromtimestamp(cleandate).strftime('%Y-%m-%d'))
|
||||
return datetime.fromtimestamp(cleandate).strftime('%Y-%m-%d')
|
||||
return datetime.fromtimestamp(cleandate).strftime('%Y-%m-%d')
|
||||
return "NOTFound"
|
||||
def getCookieFromBrowser(url):
|
||||
#workaround for loked database
|
||||
shutil.copyfile(cookiePath,tmpPath)
|
||||
cookie = ''
|
||||
rows = [0]
|
||||
|
||||
with sqlite3.connect(tmpPath) as connection:
|
||||
cmd_read_cookies = f"""SELECT name,value FROM moz_cookies WHERE host like ?;"""
|
||||
print(cmd_read_cookies)
|
||||
cursor = connection.cursor()
|
||||
cursor.execute(cmd_read_cookies,('%'+'indeed'+'%',))
|
||||
while len(rows)!=0:
|
||||
rows = cursor.fetchmany(25)
|
||||
for row in rows:
|
||||
print("row:",row)
|
||||
cookie = cookie + row[0] + '=' + row[1]
|
||||
cookie += ";"
|
||||
|
||||
print("Cookies:",cookie)
|
||||
return cookie
|
||||
#access cookies from firefox:
|
||||
#copy (because locked): cp .mozilla/firefox/imibizoh.default/cookies.sqlite cookies.sqlite
|
||||
#Select value from moz_cookies where host like '%indeed%'
|
||||
|
Loading…
Reference in New Issue
Block a user