Я извлекаю историю Chrome из базы данных sqlite.Из таблицы посещений я извлекаю типы переходов.Однако, когда я пытаюсь извлечь из него квалификаторы перехода, я получаю некоторые значения, такие как «0xa0000000» или «0x32000000», которых нет в документации.Поэтому я не могу их интерпретировать.Это мой код:
con = sqlite3.connect('path')
c = con.cursor()
# Change this to your preferred query
#c.execute("select urls.id, urls.url, urls.title, urls.visit_count, urls.typed_count, datetime(("
# "urls.last_visit_time/1000000)-11644473600, 'unixepoch', 'localtime') FROM urls")
c.execute("select distinct urls.id, urls.url, urls.title, urls.visit_count, urls.typed_count, datetime(("
"urls.last_visit_time/1000000)-11644473600, 'unixepoch', 'localtime'), visits.visit_time, "
"visits.from_visit, visits.transition FROM urls, visits WHERE urls.id = visits.url")
results = c.fetchall()
def chrome_transition_types(val_transaction):
hex_val_transaction = int(hex(val_transaction), 16)
# Chrome calls 0xFF the 'CORE_MASK' because the last two hex digits make up the 'core' transition value.
# Since the transition values we are looking at are bigger than just two hex characters, I'll pad the CORE_MASK out with zeros to make it match (0x000000FF).
# Since bitwise ANDing a value with 1 simply returns the value, and 0xF = 1111 (binary), all this mask does is say we care about the last two hex digits and can drop the preceding characters.
hex_val_transaction = hex(hex_val_transaction & 0x000000FF)
return hex_val_transaction
def chrome_transition_qualifiers(value_transaction):
hex_value_transaction = int(hex(value_transaction), 16)
# The 'QUALIFIER_MASK' is 0xFFFFFF00.
hex_value_transaction = hex(hex_value_transaction & 0xFFFFFF00)
return hex_value_transaction
# Iterate over each row in the results and assign it to a variable.
for result in results:
visit_id = result[0]
visit_url = result[1]
visit_title = result[2]
visit_count = result[3]
typed_count = result[4]
last_visit_time = result[5]
visit_time = result[6]
from_visit = result[7]
visit_transitions_original = result[8]
visit_transitions = chrome_transition_types(visit_transitions_original)
visit_transitions_qualifier = chrome_transition_qualifiers(visit_transitions_original)
fp = open('store.csv', 'w')
myFile = csv.writer(fp)
myFile.writerows(results)
fp.close()
Я не могу понять, есть ли проблема в моем коде или я что-то упускаю?
Любая помощь приветствуется.
Спасибо.