Skip to main content

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

Project description

PyPI - Python Version PyPI PyPI - Downloads
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 registry 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

The library is very easy to use, these two examples might be the only methods you need to know.

Synchronously

from dmr import DMR

license_plate = "cw87553"

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

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

Asynchronously

from dmr import DMR

license_plate = "cw87553"

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

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

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 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's very slow. 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-1.0.0.tar.gz (13.7 kB view hashes)

Uploaded Source

Built Distribution

dmr.py-1.0.0-py3-none-any.whl (14.8 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