libloc
comes with native Python bindings which
are used by its main command-line tool
location
.
They are the most advanced bindings as they support reading
from the database as well as writing to it.
libloc
comes with native Python bindings which
are used by its main command-line tool
location
.
They are the most advanced bindings as they support reading
from the database as well as writing to it.
Python 3.7.3 (default, Apr 3 2019, 05:39:12)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import location
>>> d = location.Database("/usr/share/location/database.db")
>>> for i in d.search_as("Lightning Wire Labs"):
... print(i)
...
AS204867 (Lightning Wire Labs GmbH)
>>> n = d.lookup("81.3.27.38")
>>> n
<location.Network 81.3.27.0/24>
>>> n.asn
24679
>>> n.country_code
'DE'