- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我需要使用 python 读取 firefox 的 indexeddb。
我使用 slite3
包来检索 indexeddb 的内容:
with sqlite3.connect(indexeddb_file) as conn:
c = conn.cursor()
c.execute('select * from object_data;')
rows = c.fetchall()
for row in rows:
print row[2]
然而,虽然我知道数据库中的内容是字符串,但它们存储为 sqlite binary blobs .有没有办法从 python 中读取存储为 blob 的字符串?
我试过:
更新
遵循 firefox 中的编码方案 source code关于@paa 在这个问题的评论之一中指出的 indexeddb 的实现,我在 python 中实现了数据库键的部分 FF 编码方法。所以,到目前为止,我只为字符串实现了它,但为其他类型实现它会更容易:
BYTE_LENGTH = 8
def hex_to_bin(hex_str):
"""Return binary representation of hexadecimal string."""
return str(trim_bin(int(hex_str, 16)).zfill(len(hex_str) * 4))
def byte_to_unicode(bin_byte):
"""Return unicode encoding for binary byte."""
return chr(int(str(bin_byte), 2))
def trim_bin(int_n):
"""Return int num converted to trimmed bin representation."""
return bin(int_n)[2:]
def decode(key):
"""Return decoded idb key."""
decoded = key
m = re.search("[1-9]", key) # change for non-zero
if m:
i = m.start()
typeoffset = int(key[i])
else:
# error
pass
data = key[i + 1:]
if typeoffset is 1:
# decode number
pass
elif typeoffset is 2:
# decode date
pass
elif typeoffset is 3:
# decode string
bin_repr = hex_to_bin(data)
decoded = ""
for i in xrange(0, len(bin_repr), BYTE_LENGTH):
byte = bin_repr[i:i + BYTE_LENGTH]
if byte[0] is '0':
byte_1 = int(byte, 2) - 1
decoded += byte_to_unicode(trim_bin(byte_1))
else:
byte = byte[2:]
if byte[1] is '0':
byte_127 = int(byte, 2) + 127
decoded += byte_to_unicode(trim_bin(byte_127))
i += BYTE_LENGTH
decoded += byte_to_unicode(bin_repr[i:i + BYTE_LENGTH])
elif byte[1] is '1':
decoded += byte_to_unicode(byte)
i += BYTE_LENGTH
decoded += byte_to_unicode(bin_repr[i:i + BYTE_LENGTH])
i += BYTE_LENGTH
decoded += byte_to_unicode(bin_repr[i:i + 2])
return decoded
elif typeoffset is 4:
# decode array
pass
else:
# error
pass
return decoded
但是,我仍然无法解码 indexeddb 的数据字段。在我看来,他们没有使用任何复杂的方案,例如 key 方案,因为当我以 UTF-16 编码时,我可以读取实际值的某些部分。
最佳答案
(在这里打字,因为我还不能发表评论...)
对于数据本身,我一直在尝试对数据 blob 做同样的事情。对于我的问题,我正在尝试获取 JSON 字符串。如果我查看要筛选的数据库,大多数时候我确实会看到 UTF-16 编码的字符。但在某些奇怪的情况下,我有这个:
“我们开始”被编码为 7400 6800 6500 7200 6500 2000 77 [05060C] 6700 6F00。 [05060C] 应该编码为“e”。
https://mxr.mozilla.org/mozilla-release/source/dom/indexedDB/IDBObjectStore.cpp
我正在努力调查,看看是否有任何线索。目录中应该有很多其他源文件可以提供帮助。
关于python - 如何使用 Python 访问 Firefox 的内部 indexedDB 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22917139/
是否可以从浏览器外部或创建它的域外部访问 IndexedDB? 我正在考虑将数据存储到与某个特定域相关的某些 IndexedDB 的情况,因为它总是这种情况,然后在第一个域不复存在后访问该数据,或将其
我有一个员工在断开连接模式下使用的渐进式网络应用程序。他们扫描商店中的库存商品,该应用程序搜索本地数据以查找扫描的商品(indexedDb 数据存储,约有 1/2 百万条记录)。 此数据通过 API
有人可以告诉我是否可以使用 index、openCursor 和 keyRange 在 indexeddb 对象存储上执行不区分大小写的搜索.... 我可以区分大小写并设法使用 toUpperCase
来自提供的示例here和 here 它们展示了创建请求,然后在发出请求后附加 onerror 和 onsuccess 处理程序。 var transaction = db.transaction(["
假设您正在构建一个框架 Foobar,并假设 Foobar 有一个函数 .coolstuff(),它会调用 IndexedDB 调用 .coolstuff2() 和 .coolstuff3(),当这两
只要您使用适当的 IDBTransaction,是否可以从单个事务中完成所有这些操作,而不是打开多个事务(读取表、写入表、写入另一个表等)? Mozilla 说:“保持事务处于事件状态的唯一方法是对其
我有一个小项目,将数据存储在浏览器的 IndexedDB 中。我想添加同步功能,以便用户可以在任何地方访问数据。 如何在远程服务器或服务器数据库中同步本地 IndexedDB 数据,以便我可以在任何地
我想在 onupgradeneeded 中更新我的 indexeddb 数据库的对象库之一。我想检查一下,如果这个索引存在于这个对象存储中,那么就不需要做任何更改。但如果不是,我想更新它的索引。 最佳
有没有办法检查 IndexedDB 数据库是否已经存在?当程序试图打开一个不存在的数据库时,该数据库被创建。 我能想到的唯一方法是如下所示,我测试 objectStore 是否已经存在,如果不存在,则
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我的代码如下: ... var f1 = function(trans) { var store = trans.objectStore('ObjectStore'); store.clear
我在我的一页中创建了一个 IndexdDB 对象存储(让对象存储名称为“ShopStore”)。现在我想从不同的页面打开相同的对象存储。可能吗? 我的两个网页位于不同的域。 最佳答案 根据MDN您无法
我有一个 Epub 注释插件,用户可以在其中对 Epub 进行注释,但是注释文本存储在浏览器中的 indexeddb 数据库中,想将这些注释文本导出到文件中,而在其他系统中,我想将这些文件导入到我的
在之前的 IndexedDB 规范 ( http://www.w3.org/TR/2011/WD-IndexedDB-20111206 ) 中,IDBDatabase 事务的模式值很短。在当前规范(2
有没有办法对 IndexedDB 中的同一属性进行 OR 或 IN 查询? 换句话说,我如何得到结果, SELECT * FROM MyTable WHERE columnA IN ('ABC','D
据我了解,IndexedDB 是大多数跨浏览器在线数据库解决方案的方式。甚至可能在 FF 等浏览器中使用这个 polyfill。 我试图找到一个非常简单的页面,它使用 IndexedDB 最初填充数据
给定一个带有一个声明对象存储的 indexeddb 数据库: var objectStore = thisDb.createObjectStore("table", {keyPath: "id", a
我正在构建一个利用 IndexedBD 的网络应用程序。我来自 SQL 背景,所以概念不同。具体来说,我的理解是 indexedDB 中没有“外键”的真正概念。因此,我试图找出检索相关对象的最快方法,
我在不做任何其他修改的情况下升级版本时遇到此代码问题,我无法理解原因。 function create_registry() { var version = 1; var indexe
我使用下面的代码从 indexeddb 中选择所有列 this._connection.openDb(this._indexedDBLiveDBName); return this._
我是一名优秀的程序员,十分优秀!