A Python 3 interface for working with Geocaching.com website.
- login to Geocaching.com
- search caches
- normal search (unlimited number of caches from any point)
- quick search (all caches inside some area)
- load cache details by WP
- normal loading (loads all details)
- quick loading (loads just basic info very quickly)
- lazy loading (create cache object and load info on demand)
- load trackable details by tracking-code
- geocode given location
- search results caching (not geo- :)
- Sphinx documentation
- submitting cache logs
- usage of asyncio
- automatic generation of possible cache attributes - partially done
Using pip:
pip install pycaching
Manually, from GIT:
git clone https://github.com/tomasbedrich/pycaching.git
- Python >= 3.0 (>= 3.4 required for running tests)
- MechanicalSoup >= 0.3.0
- geopy >= 1.0.0
import pycaching
geocaching = pycaching.login("user", "pass")
The above is just shortcut for:
from pycaching import Geocaching
geocaching = Geocaching()
geocaching.login("user", "pass")
import pycaching
geocaching = pycaching.login("user", "pass")
cache = geocaching.load_cache("GC12345")
print(cache.name)
Using lazy loading:
from pycaching import Geocaching, Cache
geocaching = Geocaching()
geocaching.login("user", "pass")
cache = Cache("GC12345", geocaching)
print(cache.name)
The difference is, that Cache
object is created immediately and the page is loaded when needed (accessing the name).
Notice the limit
in search function. It is because search()
returns a generator object, which would fetch the caches forever in case of simple loop.
from pycaching import Geocaching, Point
point = Point(10.123456, 10.123456)
geocaching = Geocaching()
geocaching.login("user", "pass")
for cache in geocaching.search(point, limit=50):
if cache.cache_type == "Traditional Cache":
print(cache.name)
import pycaching
geocaching = pycaching.login("user", "pass")
point = geocaching.geocode("10900 Euclid Ave in Cleveland")
for cache in geocaching.search(point, limit=10):
print(cache.name)
from pycaching import Geocaching, Point, Rectangle
geocaching = pycaching.Geocaching()
geocaching.login("user", "pass")
rect = Rectangle(Point(60.15, 24.95), Point(60.17, 25.00))
for c in geocaching.search_quick(rect, strict=True):
print('{:8} ({:.5f}, {:.5f}) (+- {:.1f} m); {}'.format(
c.wp, c.location.latitude, c.location.longitude,
c.location.precision, c.name))
import pycaching
geocaching = pycaching.login("user", "pass")
travelbug = geocaching.load_trackable("TB3ZGT2")
print("Goal:\n", travelbug.goal,
"\n\nDescription:\n", travelbug.description,
"\n\nCurrent Location:\n", travelbug.location)
Notice the limit
in search function. It is because search()
returns a generator object, which would fetch the caches forever in case of simple loop.
from pycaching import Geocaching, Point
point = Point(56.25263, 15.26738)
geocaching = Geocaching()
geocaching.login("user", "pass")
for cache in geocaching.search(point, limit=50):
if len(cache.trackables) > 0:
print(cache.name)
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.