On Tue 20 May 2014 17:08:47 CEST, Klaus Darilion wrote:
Hi Daniel!
Hi!
Actually I tried it today but failed obviously due to my lack of Python.
It would be great if you could add an example to the README e.g. with
full result parsing:
- load the json file from disk
- loop over every result (json list)
- print some value
The full documentation already has a few examples that should be enough to get you going (I’ve just added some more), but here’s a breakdown of what you’re wanting:
from ripe.atlas.sagan import Result
my_results_file = "/path/to/file.txt"
with open(my_results_file) as results:
for result in results.readlines():
parsed_result = Result.get(result)
print(parsed_result.origin)
Once you have a parsed_result
,
you have access to all of the properties of that result, which
are defined
in the full documentation.
Why do I have to use the responses[0] object? Can there be multiple
responses with different nsids?
In some cases, DNS
results can contain multiple responses. In an effort
to maintain consistency for all DNS results, we opted to treat
all DNS results as if they contain a list of responses — even if
that list is of only one response. This makes it easier to write
scripts that make use of the object, since you always have a
consistent data type in parsed_result.responses
.
I hope that helps!