Skip to main content

Interact with Google Chrome local storage

Project description

Chrome Local Storage

Tests Linter Security Release

This Python package makes it easy to interact with Google Chrome local storage, either a locally-running browser or any remote browser that supports remote debugging (e.g. Chrome on Android via adb port forwarding).

Prerequisites

Installation is via pip:

pip install chrome-local-storage

Chrome must be running with the debugging port active for the library to connect. There are various methods to do this, for example, on Windows:

chrome.exe --remote-debugging-port=9222

And on MacOS:

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222

The library will also work on any mobile device that supports remote debugging on Chrome, For example, on Android, use the Android Debug Bridge to set up a port forward as follows:

adb forward tcp:9222 localabstract:chrome_devtools_remote

In all of the above examples, the debugger will be available at localhost:9222 which is what the library expects by default.

Usage

Basic usage is as follows:

import chrome_local_storage

local_storage = chrome_local_storage.ChromeLocalStorage()

local_storage.set('example.com', 'my-key', 'my-value')
value = local_storage.get('example.com', 'my-key')
print(value)

The first parameter in both get and set determines the page whose local storage will be used for the operation. The page must already be open in the browser, and it does not have to be an exact match to the whole URL as long as it's unique across open pages.

In a more complex example, two constructors connect to two different Chrome instances and copy Wordle statistics from one to the other (the desire to transfer my streak from one device to another was the original motivation for building this library).

chrome --remote-debugging-port=9222 "https://nytimes.com/games/wordle"
adb forward tcp:9223 localabstract:chrome_devtools_remote
import chrome_local_storage

laptop_storage = chrome_local_storage.ChromeLocalStorage(port=9222)
phone_storage = chrome_local_storage.ChromeLocalStorage(port=9223)

wordle_stats = laptop_storage.get('games/wordle', 'nyt-wordle-statistics')
phone_storage.set('games/wordle', 'nyt-wordle-statistics', wordle_stats)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chrome-local-storage-0.6.0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chrome_local_storage-0.6.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file chrome-local-storage-0.6.0.tar.gz.

File metadata

  • Download URL: chrome-local-storage-0.6.0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.9.12 Linux/5.13.0-1022-azure

File hashes

Hashes for chrome-local-storage-0.6.0.tar.gz
Algorithm Hash digest
SHA256 aa79503bae70703c70131fc02bb1032182f143a3da7b0babc5b630ee25237f74
MD5 0e19905b5f15fe3849fd2c72f76fbb0f
BLAKE2b-256 22955abe278d5f6b12e46f77eba1122f2b08b4c0fb0256476147594283c4c81f

See more details on using hashes here.

File details

Details for the file chrome_local_storage-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: chrome_local_storage-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.9.12 Linux/5.13.0-1022-azure

File hashes

Hashes for chrome_local_storage-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 da6a7453812ce887d871ea54adb07263515af3acd725ca4fc85eff2153b0e0c7
MD5 08bd71278224fe2cf01f0fa4b9bd3272
BLAKE2b-256 9680b2d7519d508a7f0c11ae05a5cb0b1bcf5fefe12cc705b145951ecc80747a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page