Complete documentation can be found at Read the Docs.
- login to Geocaching.com
- search caches
- normal search (unlimited number of caches from any point)
- quick search (all caches inside some area)
- get cache and its details
- normal loading (can load all details)
- quick loading (can load just basic info but very quickly)
- load logbook for given cache
- get trackable details by tracking code
- post log to cache logbook
- geocode given location
Stable version - using pip:
pip install pycaching
Dev version - manually from GIT:
git clone https://github.com/tomasbedrich/pycaching.git
cd pycaching
pip install .
Pycaching has following requirements:
Python>=3.4 requests>=2.8 beautifulsoup4>=4.4 geopy>=1.11
Simly call :meth:`.login` method and it will do all things for you.
import pycaching
geocaching = pycaching.login("user", "pass")
If you won't provide an username or password, pycaching will try to load
.gc_credentials
file from current directory or home folder. It will try to
parse it as JSON and use the keys username
and password
from that file
as login credentials.
import pycaching
geocaching = pycaching.login() # assume the .gc_credentials file is presented
cache = geocaching.get_cache("GC1PAR2")
print(cache.name) # cache.load() is automatically called
print(cache.location) # stored in cache, printed immediately
This uses lazy loading, so the :class:`.Cache` object is created immediately and the page is loaded when needed (accessing the name).
You can use different method of loading cache details. It will be much faster, but it will load less details:
cache = geocaching.get_cache("GC1PAR2")
cache.load_quick() # takes a small while
print(cache.name) # stored in cache, printed immediately
print(cache.location) # NOT stored in cache, will trigger full loading
You can also load a logbook for cache:
for log in cache.load_logbook(limit=200):
print(log.visited, log.type, log.author, log.text)
Or its trackables:
for trackable in cache.load_trackables(limit=5):
print(trackable.name)
geocaching.post_log("GC1PAR2", "Found cache in the rain. Nice place, TFTC!")
It is also possible to call post_log on :class:`.Cache` object, but you would have to create :class:`.Log` object manually and pass it to this method.
from pycaching import Point
from pycaching.cache import Type
point = Point(56.25263, 15.26738)
for cache in geocaching.search(point, limit=50):
if cache.type == Type.traditional:
print(cache.name)
Notice the limit
in search function. It is because :meth:`.Geocaching.search`
returns a generator object, which would fetch the caches forever in case
of simple loop.
point = geocaching.geocode("Prague")
for cache in geocaching.search(point, limit=10):
print(cache.name)
from pycaching import Point, Rectangle
rect = Rectangle(Point(60.15, 24.95), Point(60.17, 25.00))
for cache in geocaching.search_quick(rect, strict=True):
print(cache.name, cache.location.precision)
trackable = geocaching.get_trackable("TB3ZGT2")
print(trackable.name, trackable.goal, trackable.description, trackable.location)
Be sure to read Geocaching.com's terms of use. By using this piece of software you break them and your Geocaching account may be suspended or even deleted. To prevent this, I recommend you to load the data you really need, nothing more. This software is provided "as is" and I am not responsible for any damage possibly caused by it.
Original version was inspired by these packages:
- Geocache Grabber (by Fuad Tabba)
- geocaching-py (by Lev Shamardin)
Although the new version was massively rewritten, I'd like to thank to their authors.
Authors of this project are all contributors. Maintainer is Tomáš Bedřich.