D
D
demortall2021-11-08 13:49:45
Python
demortall, 2021-11-08 13:49:45

How to pass this json element?

{'result':
     {'id': 'daa0845856af046bf66d8f02c62a771a',
         'name': 'cums.com',
          'status': 'pending',
           'paused': False,
            'type': 'full',
             'development_mode': 0,
              'name_servers': ['maciej.ns.cloudflare.com', 'mckinley.ns.cloudflare.com'],
               'original_name_servers': ['ns1.flyingcroc.net', 'ns2.flyingcroc.net'],
                'original_registrar': 'sea wasp, llc (id: 411)', 
'original_dnshost': None,
 'modified_on': '2021-11-08T10:33:42.821823Z', 
'created_on': '2021-11-08T10:33:42.821823Z', 
'activated_on': None, 'meta': {'step': 4, 'wildcard_proxiable': False, 'custom_certificate_quota': 0, 'page_rule_quota': 3, 'phishing_detected': False, 'multiple_railguns_allowed': False}, 'owner': {'id': 'e7deaef7d89ae66a6551553253f8fb0b', 'type': 'user', 'email': '[email protected]'}, 'account': {'id': 'aba04b79db275f830b77e897a223d04e', 'name': '[email protected]'}, 'permissions': ['#access:edit', '#access:read', '#analytics:read', '#app:edit', '#auditlogs:read', '#billing:edit', '#billing:read', '#cache_purge:edit', '#dns_records:edit', '#dns_records:read', '#lb:edit', '#lb:read', '#legal:edit', '#legal:read', '#logs:edit', '#logs:read', '#member:edit', '#member:read', '#organization:edit', '#organization:read', '#ssl:edit', '#ssl:read', '#stream:edit', '#stream:read', '#subscription:edit', '#subscription:read', '#teams:edit', '#teams:pii', '#teams:read', '#teams:report', '#waf:edit', '#waf:read', '#webhooks:edit', '#webhooks:read', '#worker:edit', '#worker:read', '#zone:edit', '#zone:read', '#zone_settings:edit', '#zone_settings:read'], 'plan': {'id': '0feeeeeeeeeeeeeeeeeeeeeeeeeeeeee', 'name': 'Free Website', 'price': 0, 'currency': 'USD', 'frequency': '', 'is_subscribed': False, 'can_subscribe': False, 'legacy_id': 'free', 'legacy_discount': False, 'externally_managed': False}}, 'success': True, 'errors': [], 'messages': []}

This is the answer from cloudflare.
I need to take 'name_servers': ['maciej.ns.cloudflare.com', 'mckinley.ns.cloudflare.com'], or rather its two arguments, i.e.: 'maciej.ns.cloudflare.com', 'mckinley.ns.cloudflare.com'
Naturally I tried first myself but didn't work
res = requests.post(f"https://api.cloudflare.com/client/v4/zones", headers=headers, data=data)
                res_json = res.json()   
                        for result in res_json["result"]:
                            for ns in result[5]:
                                  print(ns[0], ns[1])

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-11-08
@demortall

res_json['result']['name_servers']
?
https://pythonworld.ru/tipy-dannyx-v-python/slovar...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question