Skip to main content

Pull data directly from the danish vehicle register with dmr.py

Project description

PyPI - Python Version PyPI PyPI - Downloads
GitHub Workflow Status GitHub BuyMeACoffee

dmr.py

You will no longer need an exspensive API for danish license plate lookups with dmr.py, this tool scrapes the danish vehicle register directly and returns the data for you to use in your application. Be aware, that because of skat.dk's very slow database lookups, it could take about 3-4 seconds before getting a response.

Installation:

Install with pip

python -m pip install dmr.py

If you want to install the additional speedup packages, you can use the command below. These speedup packages is only for the async part of this library. If you are only using the synchronous part, then this is unnecessary.

python -m pip install dmr.py[speed]

Install current code from this repo, you will need to have git installed in order to do this. The code in the repo might not match the current release, if you experience errors you should switch back the the latest release.

python -m pip install git+https://github.com/j4asper/dmr.py

Example

Synchronously

from dmr import DMR

license_plate = "cw87553"

# Get DMR object with data
vehicle = DMR(license_plate).get_by_plate()

print("The vehicle make is:", vehicle.make)
# The vehicle make is: Suzuki

Asynchronously

from dmr import DMR

license_plate = "cw87553"

# Get DMR object with data
vehicle = await DMR(license_plate).get_by_plate_async()

print("The vehicle make is:", vehicle.make)
# The vehicle make is: Suzuki

All attributes to the DMR() object can be viewed in the Wiki

Contributing:

I would be more than happy if those who know how to make pull requests, contribute with code! Sometimes XPaths may not match with the ones on the danish vehicle register, if that's the case, then you can either make a pull request with XPath fixes or make an issue saying that the XPaths are wrong, then i will fix it. XPaths are kept in this file.

ToDo:

  • Add from_dict and to_dict functions.
  • Add documentation with all possible values.
  • Scrape more parts of the DMR site to get even more data.
  • Add more broad tests with different types of cars or bikes.

Issue we can't do anything about.

If you have used this tool, you might notice that it is slow AF. That is probably due to our government using multiple 80-100 GB XML files as the databse for all vehicles in Denmark. It roughly takes about 3 seconds to do a lookup on the DMR site. Caching is highly recommended!

License Plates for testing:

You can use all the license plates listed in This file for testing. If a license plate turns out to be invalid, please remove it and make a PR, or create an issue stating this.

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

dmr.py-0.0.9.tar.gz (14.0 kB view hashes)

Uploaded Source

Built Distribution

dmr.py-0.0.9-py3-none-any.whl (13.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page