Python CLI 编辑 Firefox 书签?
有人用 Python CLI 来编辑 Firefox 书签吗? 我的世界观是 Unix 文件树;我想
- 在给定或给定或所有子树中的所有字段中查找 /re/
- cd
- ls 与上下文
- mv this ../there/
无论它使用 bookamrks.html 还是 place.sqlite 都是次要的 - 无论哪个更容易。
添加说明:我很乐意退出 Firefox,在 CLI 中编辑书签,在 Firefox 中导入新数据库。 换句话说,数据库锁定是一个有争议的问题。首先让我们看看粗略的 CLI 代码。
(为什么是文本 CLI 而不是 GUI ? CLI 更简单(对我来说),并且可以轻松编程,例如 mv old-bookmarks to 2009/same-struct/
。 尽管如此,对于 Firefox 或其他任何东西来说,指向一个非常好的书签 GUI 的链接也很有用。)
Has anyone done a Python CLI to edit Firefox bookmarks ?
My worldview is that of Unix file trees; I want
- find /re/ in given or all fields in given or all subtrees
- cd
- ls with context
- mv this ../there/
Whether it uses bookamrks.html or places.sqlite is secondary -- whatever's easier.
Clarification added: I'd be happy to quit Firefox, edit bookmarks in the CLI, import the new database in Firefox.
In otherwords, database locking is a moot point; first let's see code for a rough cut CLI.
(Why a text CLI and not a GUI ?
CLIs are simpler (for me), and one could easily program e.g.mv old-bookmarks to 2009/same-structure/
.
Nonetheless links to a really good bookmarker GUI, for Firefox or anything else, would be useful too.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
假设我们谈论的是 Firefox 3 或更高版本,书签保存在 SQLite 文件中,places.sqlite< /a> 个人资料文件夹。因此,您需要一个例程来查找配置文件文件夹(取决于您的平台),然后您可以加载 SQLite 文件。
该模式丰富且有点复杂,但有良好的文档记录,当然,借助 Python 的 SQLite 支持,您可以交互式地探索它。
当然,Firefox 在运行时会锁定数据库。对于只读访问,您只需将 place.sqlite 复制到临时文件中,然后打开并浏览该文件;然而,要按照您的要求执行更改,似乎最好要求用户退出 Firefox(如果这是不可接受的,您可以探索 Firefox 是否提供了一种请求其合作的方法)。
这就是你的想法吗……?
Assuming we're talking about Firefox 3 or better, the bookmarks are kept in a SQLite file, places.sqlite in the profile folder. So you need a routine to find the profile folder (depending on your platform) and then you can load the SQLite file.
The schema's rich and a bit complicated, but well documented, and of course with Python's SQLite support you can explore it interactively.
Of course, Firefox keeps the DB locked when it's running. For read-only access, you can just copy places.sqlite into a temporary file, then open and explore that one; to perform changes as you seem to require, however, it seems best to require the user to quit Firefox (if that's unacceptable, you could explore if Firefox offers a way to ask for its cooperation).
Is this the kind of things you had in mind...?
我不知道您提到的所有功能,但“书签”菜单中的“组织书签”选项在功能方面相当不错。
I don't know about all the features you've mentioned but "Organize bookmars" option in the Bookmarks menu is pretty decent with respect to features.