简体   繁体   English

如何从 Python 读取/修改 HTML5 本地存储的本地文件?

[英]How to read/modify a local file of HTML5 Local Storage from Python?

I did an Ubuntu Webapp and I'd like to create a Preferences dialog with a litte hack.我做了一个Ubuntu Webapp ,我想用一个小技巧创建一个首选项对话框。

From the webapp I can storage/retrieve values with HTML5:从 webapp 我可以使用 HTML5 存储/检索值:

if (localStorage.getItem('showNotifications')) {
    // Enabling notifications...
}

I found this file in Ubuntu:我在 Ubuntu 中找到了这个文件:

/home/costales/.local/share/Telegramzhukovgithubio/Local Storage/http_zhukov.github.io_0.localstorage

I'd like to launch an independent Python dialog with a few preferences (show notifications, autostart...), that python app reads/writes values in that file, then the webapp will read it and setting that configuration.我想启动一个带有一些首选项(显示通知、自动启动...)的独立 Python 对话框,该 Python 应用程序读取/写入该文件中的值,然后 Web 应用程序将读取它并设置该配置。

Is possible to read/write that values from the .localstorage file in Python?是否可以从 Python 中的 .localstorage 文件读取/写入这些值? Please,how?请问怎么办? Thanks in advance!提前致谢!

This worked :)这有效:)

import sqlite3
conn = sqlite3.connect('/home/costales/.local/share/Telegramzhukovgithubio/Local Storage/http_zhukov.github.io_0.localstorage')
c = conn.cursor()
c.execute("SELECT key,value FROM ItemTable where key='count'")
print c.fetchone()
conn.close()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用python请求修改本地存储 - How to modify local storage with python requests 有没有办法只在azure blob存储中读取和修改.ini文件的内容,而无需使用python将其下载到本地? - Is there any way to read and modify the contents of .ini file in azure blob storage only , without downloading it in the local using python? 如何使用 Python 读取本地存储? - How to read local storage using Python? 如何直接从 Azure blob 存储读取文本文件而不将其下载到本地文件(使用 python)? - How can I read a text file from Azure blob storage directly without downloading it to a local file(using python)? 如何使用python从服务器读取本地PC中的文件 - how to read file in local PC from server with python 如何在python live plot中从本地txt文件读取数据 - How to read data from local txt file in python live plot 使用Python从Google App读取本地文件 - Read local file from Google App with Python 如何使用python将本地html文件中的信息保存在文本文档中? - how to save info from local html file in a text document with python? 如何在python中修改本地命名空间 - How to modify the local namespace in python 如何像在内存中一样读取本地存储中的文件并将其附加到电子邮件中? - How to read a file in my local storage as in memory and attach it into email?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM