Python wrapper library for the 'dig' command line tool
pydig is a python wrapper library for the 'dig' command line tool.
pydig follows SemVer (MAJOR.MINOR.PATCH) to track what is in each release.
- Major version number will be bumped when there is an incompatible API change
- Minor version number will be bumped when there is functionality added in a backwards-compatible manner.
- Patch version number will be bumped when there is backwards-compatible bug fixes.
Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.
Installation the package from pypi with your tool of choice
pip install pydig
To use the default resolver you can call
pydig.query this resolver will use
dig command found in your
>>> import pydig >>> pydig.query('example.com', 'A') ['126.96.36.199'] >>> pydig.query('www.github.com', 'CNAME') ['github.com.'] >>> pydig.query('example.com', 'NS') ['a.iana-servers.net.', 'b.iana-servers.net.']
If your want to adjust the executable location, the nameservers to dig will
query against or would like to pass additional arguments/flags, you can
configure your own instance of a resolver. and call the
query method of your
>>> import pydig >>> resolver = pydig.Resolver( ... executable='/usr/bin/dig', ... nameservers=[ ... '188.8.131.52', ... '184.108.40.206', ... ], ... additional_args=[ ... '+time=10', ... ] ... ) >>> resolver.query('example.com', 'A') >>> ['220.127.116.11']
The code is 150~ lines with 100% test coverage
If you’re interested in financially supporting open source, consider donating.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.