Skip to main content

Geocaching.com site crawler. Provides tools for searching, fetching caches and geocoding.

Project description

A Python 3 interface for working with Geocaching.com website.

Features

  • 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

Installation

Using pip:

pip install pycaching

Manually, from GIT:

git clone https://github.com/tomasbedrich/pycaching.git

Requirements

  • Python >= 3.0 (>= 3.4 required for running tests)

  • MechanicalSoup >= 0.3.0

  • geopy >= 1.0.0

Example usage

Login

import pycaching
geocaching = pycaching.login("user", "pass")

The above is just shortcut for:

from pycaching import Geocaching
geocaching = Geocaching()
geocaching.login("user", "pass")

Load a cache details

import pycaching

geocaching = pycaching.login("user", "pass")
cache = geocaching.load_cache("GC1PAR2")
print(cache.name)

Using lazy loading:

from pycaching import Geocaching, Cache

geocaching = Geocaching()
geocaching.login("user", "pass")
cache = Cache("GC1PAR2", geocaching)
print(cache.name)

The difference is, that Cache object is created immediately and the page is loaded when needed (accessing the name).

Find all traditional caches around

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 cache.cache_type == "Traditional":
        print(cache.name)

Find all caches on some adress

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)

Find approximate location of caches in area

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 cache in geocaching.search_quick(rect, strict=True):
    print(cache.name, cache.location.precision)

Load trackable details

import pycaching
geocaching = pycaching.login("user", "pass")
trackable = geocaching.load_trackable("TB3ZGT2")
print(trackable.goal, trackable.description, trackable.location)

Find all nearby caches with trackables in them

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)

Appendix

Inspiration

Original version was inspired by these packages:

Although the new version was massively rewritten, I’d like to thank to their authors.

Author

Tomas Bedrich

Build Status Coverage Status PyPI monthly downloads

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

pycaching-3.2.tar.gz (28.6 kB view details)

Uploaded Source

File details

Details for the file pycaching-3.2.tar.gz.

File metadata

  • Download URL: pycaching-3.2.tar.gz
  • Upload date:
  • Size: 28.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pycaching-3.2.tar.gz
Algorithm Hash digest
SHA256 838fd8b3a7f229ff2f2c51fad8d4e67cd2e7a65b92e20746d4d39ebfd15b1533
MD5 945181b189f55276c1ca5fc395ada834
BLAKE2b-256 d71f131c9c9a6737f5f8675476911f2a9dd0948b9dd76f22b4143bcc7d165e87

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