Skip to main content

Fetch Cavelink data by parsing the webpage of sensors.

Project description

Build Status

What is this repository for?

This python module gather the data by parsing the webpage. You will then be able to display the data on your dashboard or store it to your own database. I also provide code samples to better explain this -see directory ‘samples’-.

How do I get set up?

To ensure a proper setup, I recommend the use of virtualenv (but optionnal).

sudo apt-get update && sudo apt-get install git python-pip --yes
mkdir your-project
cd your-project
virtualenv venv
source venv/bin/activate
sudo pip install cavelink

Then you can use the module that way:

>>> from cavelink import cavelink
>>> webpage="http://www.cavelink.com/cl/da.php?s=142&g=10&w=1&l=10"
>>> nb_rows = 5
>>> cvlnk = cavelink.Sensor(webpage, nb_rows)
>>> motiers = cvlnk.getJSON(datefmt='human')  # or datefmt='epoch'
>>> motiers_json = json.loads(motiers)
>>>
>>> for timestamp in motiers_json['measures']:
>>>    print('%s : %s %s' % (key,
>>>                           motiers_json['measures'][timestamp],
>>>                           motiers_json['sensor']['unit']))

You can also fetch additionnal information, also available from the page. Please note that the following data is provided in JSON object as well. This is:

>>> print(cvlnk.station)
>>> print(cvlnk.group)
>>> print(cvlnk.number)
>>> print(cvlnk.unit)

Contribution guidelines

Feel free to submit issue or better, some pull requests !

Contributors

  • Sébastien Pittet (main contributor)
  • Loïc, Bruno and other friends at exoscale.com

Who do I talk to?

sebastien at pittet dot org

Project details


Download files

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

Files for cavelink, version 1.1.0
Filename, size File type Python version Upload date Hashes
Filename, size cavelink-1.1.0-py3-none-any.whl (6.0 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size cavelink-1.1.0.tar.gz (4.9 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page