A simple URL caching library for Python
Project description
sam_url_cache
A simple Python package for caching the contents of URLs using SQLite. This helps avoid repeated network requests for the same URL.
Features
- Caches URL responses in a local SQLite database.
- Automatically fetches and stores content on cache miss.
- Simple API for checking if a URL has been seen before.
Installation
Install via pip
pip install sam-url-cache
Usage
from sam_url_cache import URLCache
cache = URLCache() # Uses default database path 'url_cache.db'
# Fetch and cache a URL
content = cache.getURL('https://example.com')
# Check if a URL has been seen before
if cache.seen_before('https://example.com'):
print("URL is cached!")
Object
URLCache(databse_path: str = 'url_cache.db')
Create a new URL cache instance. Optionally specify a custom database path.
get_url(url: str) -> str
Fetch the content of the URL. Returns cached content if available, otherwise fetches from the web and caches it.
seen_before(url: str) -> bool
Check if the URL is already cached.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sam_url_cache-0.3.tar.gz.
File metadata
- Download URL: sam_url_cache-0.3.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d23eb5887b44dcdc099804495722a9c1f2a24946bd9342ffe015fee15fd6917
|
|
| MD5 |
c19c24d8e1ad4265346e0a86448929d4
|
|
| BLAKE2b-256 |
66a743d2dc5691d5d9285db69415cf8f1c23cbb46b89fa8ea3cd30c955c6d309
|
File details
Details for the file sam_url_cache-0.3-py3-none-any.whl.
File metadata
- Download URL: sam_url_cache-0.3-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54a0395258c68dc220f85484fe2b9616dd9cc36c74747111dd377ec8aa168023
|
|
| MD5 |
724933c2ffa9052d728891f323a7c6b3
|
|
| BLAKE2b-256 |
5d26dde7c289f83359ff659e677e787ceb50da996f50c02d714e1f567611ad56
|