Name | python-bvk JSON |
Version |
0.3.1
JSON |
| download |
home_page | https://github.com/dankeder/python-bvk |
Summary | Python library for tracking water consumption from BVK (Brnenske vodarny a kanalizace, bvk.cz) |
upload_time | 2024-05-04 18:52:56 |
maintainer | None |
docs_url | None |
author | Dan Keder |
requires_python | None |
license | None |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# python-bvk
Water conspmution scraper for BVK (Brnenské vodárny a kanalizace, bvk.cz)
Note that you need to have the "smart" water-gauge installed. If you don't know
what that is you probably don't have one. If you don't have one you have to ask
them (BVK) to install it for you and you may have to wait a potentially long
time - they are rolling them out gradually.
## Install
```
pip install python-bvk
```
## Usage
To create the client object you need to provide your BVK username/password
(the one you use on the customer portal https://zis.bvk.cz/).
```
from bvk import Bvk
from dateutil import parser
# Create client
bvk = Bvk('username', 'password')
```
Use `getwaterConsumption()` method to get the water consumption data. It accepts
a `date_from` and optionally a `date_to`, both of which have to be a
[datetime.date](https://docs.python.org/3/library/datetime.html#datetime.date)
object. If `date_to` is not specified the method returns data to today.
Examples:
```
# Get water consumption data from the specified date to now
date_from = parser.parse('2020-08-01').date()
deferred_data = bvk.getWaterConsumption(date_from);
# Get water consumption data for a date interval
date_from = parser.parse('2020-08-01').date()
date_to = parser.parse('2020-08-11').date()
deferred_data = bvk.getWaterConsumption(date_from, date_to);
# Get water consumption data for a specific date (just 1 day)
date = parser.parse('2020-08-01').date()
deferred_data = bvk.getWaterConsumption(date, date);
```
You may call `getWaterConsumption` multiple times with different parameters. It
returns a
[twisted.internet.defer.Deferred](https://twistedmatrix.com/documents/current/core/howto/defer.html)
object that can be used to retrieve the price data in the future using a
callback you need to provide.
```
def process_consumption(consumption)
print(consumption)
deferred_data.addCallback(process_consumption)
```
If you have multiple `Deferred`s from multiple calls to `getWaterConsumption`
you can use `Bvk.join()` to get a `Deferred` that will be resolved after all
crawlers are finished.
The last callback should stop the reactor so it's shut down cleanly. Reactor
should be stopped after all crawlers are done so the `join()` method comes in
handy. Note that the reactor cannot be restarted so make sure this is the last
thing you do:
```
from twisted.internet import reactor
d = bvk.join()
d.addBoth(lambda _: reactor.stop())
```
The last thing you need to do is run the reactor. The script will block until
the crawling is finished and all configured callbacks executed.
```
reactor.run(installSignalHandlers=False)
```
Keep in mind the library is using [Scrapy](https://scrapy.org) internally which means it is
scraping the BVK customer portal to get the data. If BVK comes to think you are
abusing the website they may block your IP address and/or account.
# License
See [LICENSE](./LICENSE).
Raw data
{
"_id": null,
"home_page": "https://github.com/dankeder/python-bvk",
"name": "python-bvk",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": "Dan Keder",
"author_email": "dan.keder@protonmail.com",
"download_url": "https://files.pythonhosted.org/packages/8c/55/cc271d1c8e5ff492d5f344a13362c0c114f474e5e75fb4ee180c90933d1b/python-bvk-0.3.1.tar.gz",
"platform": null,
"description": "# python-bvk\n\nWater conspmution scraper for BVK (Brnensk\u00e9 vod\u00e1rny a kanalizace, bvk.cz)\n\nNote that you need to have the \"smart\" water-gauge installed. If you don't know\nwhat that is you probably don't have one. If you don't have one you have to ask\nthem (BVK) to install it for you and you may have to wait a potentially long\ntime - they are rolling them out gradually.\n\n\n## Install\n\n```\npip install python-bvk\n```\n\n## Usage\n\nTo create the client object you need to provide your BVK username/password\n(the one you use on the customer portal https://zis.bvk.cz/).\n\n```\nfrom bvk import Bvk\nfrom dateutil import parser\n\n# Create client\nbvk = Bvk('username', 'password')\n```\n\nUse `getwaterConsumption()` method to get the water consumption data. It accepts\na `date_from` and optionally a `date_to`, both of which have to be a\n[datetime.date](https://docs.python.org/3/library/datetime.html#datetime.date)\nobject. If `date_to` is not specified the method returns data to today.\n\nExamples:\n\n```\n# Get water consumption data from the specified date to now\ndate_from = parser.parse('2020-08-01').date()\ndeferred_data = bvk.getWaterConsumption(date_from);\n\n# Get water consumption data for a date interval\ndate_from = parser.parse('2020-08-01').date()\ndate_to = parser.parse('2020-08-11').date()\ndeferred_data = bvk.getWaterConsumption(date_from, date_to);\n\n# Get water consumption data for a specific date (just 1 day)\ndate = parser.parse('2020-08-01').date()\ndeferred_data = bvk.getWaterConsumption(date, date);\n```\n\nYou may call `getWaterConsumption` multiple times with different parameters. It\nreturns a\n[twisted.internet.defer.Deferred](https://twistedmatrix.com/documents/current/core/howto/defer.html)\nobject that can be used to retrieve the price data in the future using a\ncallback you need to provide.\n\n```\ndef process_consumption(consumption)\n print(consumption)\n\ndeferred_data.addCallback(process_consumption)\n```\n\nIf you have multiple `Deferred`s from multiple calls to `getWaterConsumption`\nyou can use `Bvk.join()` to get a `Deferred` that will be resolved after all\ncrawlers are finished.\n\nThe last callback should stop the reactor so it's shut down cleanly. Reactor\nshould be stopped after all crawlers are done so the `join()` method comes in\nhandy. Note that the reactor cannot be restarted so make sure this is the last\nthing you do:\n\n```\nfrom twisted.internet import reactor\n\nd = bvk.join()\nd.addBoth(lambda _: reactor.stop())\n```\n\nThe last thing you need to do is run the reactor. The script will block until\nthe crawling is finished and all configured callbacks executed.\n\n```\nreactor.run(installSignalHandlers=False)\n```\n\nKeep in mind the library is using [Scrapy](https://scrapy.org) internally which means it is\nscraping the BVK customer portal to get the data. If BVK comes to think you are\nabusing the website they may block your IP address and/or account.\n\n\n# License\n\nSee [LICENSE](./LICENSE).\n",
"bugtrack_url": null,
"license": null,
"summary": "Python library for tracking water consumption from BVK (Brnenske vodarny a kanalizace, bvk.cz)",
"version": "0.3.1",
"project_urls": {
"Homepage": "https://github.com/dankeder/python-bvk"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4bc9f4ebcbfa6ad0c87592ce1383b8c02975ef25669bae3137d778b6a6570b64",
"md5": "e714bb2444b1178df3e3252ffb5577ee",
"sha256": "e3566fba25b8fdf10b12fa636d4b5d1feb0ec8ed181d6282e8cdbdb45024c07f"
},
"downloads": -1,
"filename": "python_bvk-0.3.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e714bb2444b1178df3e3252ffb5577ee",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 11721,
"upload_time": "2024-05-04T18:52:54",
"upload_time_iso_8601": "2024-05-04T18:52:54.590086Z",
"url": "https://files.pythonhosted.org/packages/4b/c9/f4ebcbfa6ad0c87592ce1383b8c02975ef25669bae3137d778b6a6570b64/python_bvk-0.3.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8c55cc271d1c8e5ff492d5f344a13362c0c114f474e5e75fb4ee180c90933d1b",
"md5": "d3a5787f313e3010578ffea630e8baef",
"sha256": "eddd02db788a1e2e6e772867ee395d8eba552a6eeae1edbd35c8ecf9cf1d5745"
},
"downloads": -1,
"filename": "python-bvk-0.3.1.tar.gz",
"has_sig": false,
"md5_digest": "d3a5787f313e3010578ffea630e8baef",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 10799,
"upload_time": "2024-05-04T18:52:56",
"upload_time_iso_8601": "2024-05-04T18:52:56.463464Z",
"url": "https://files.pythonhosted.org/packages/8c/55/cc271d1c8e5ff492d5f344a13362c0c114f474e5e75fb4ee180c90933d1b/python-bvk-0.3.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-04 18:52:56",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "dankeder",
"github_project": "python-bvk",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "python-bvk"
}