1

I am using the Censys api in python to programmatically look through host and grab information about them. Censys website says it returns Json formatted data and it looks like Json formatted data but, I cant seem to figure out how to tun the api response into a json object. However, if i write the json response to a json file and load it. It works fine Any ideas?

Update: Figured out issue is with nested json that the api returns. Looking for libraries to flatten it.

Main.py

c = censys.ipv4.CensysIPv4(api_id=UID, api_secret=SECRET)
for result in c.search("autonomous_system.asn:15169 AND tags.raw:iot", max_records=1):

 hostIPS.append(result["ip"]);

for host in hostIPS:

  for details in c.view(host):
    # test = json.dumps(details)
    # test = json.load(test)
    # data = json.load(details)
    data = json.loads(details)
    print(data)
2
  • 1
    What is c? Please show a minimal reproducible example Commented Feb 18, 2020 at 14:27
  • Fixed the issue Commented Feb 18, 2020 at 14:45

1 Answer 1

1

You don't need to convert it to an object, it's already json.loaded. See the implementation here: https://github.com/censys/censys-python/blob/master/censys/base.py

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.