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

匿名 (未验证) 提交于 2019-12-03 01:26:01

问题:

I did an Ubuntu Webapp and I'd like to create a Preferences dialog with a litte hack.

From the webapp I can storage/retrieve values with HTML5:

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

I found this file in 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.

Is possible to read/write that values from the .localstorage file in Python? Please,how? Thanks in advance!

回答1:

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() 


易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!