(self, response)
return flat
Flatten a parsed Whois result into a single-level dictionary.
Flatten a parsed Whois result into a single-level dictionary.
Flatten a parsed Whois result into a single - level dictionary .
def flatten_parsed_whois(self, response):
        data = response.json()
        """Flatten a parsed Whois result into a single-level dictionary."""
        try:
            w = data['response']['parsed_whois']
        except KeyError:
            return {}
        flat = OrderedDict()
        flat['domain'] =                         w['domain']
        flat['created_date'] =                   w['created_date']
        flat['updated_date'] =                   w['updated_date']
        flat['expired_date'] =                   w['expired_date']
        flat['statuses'] =                       ' | '.join(w['statuses'])
        flat['name_servers'] =                   ' | '.join(w['name_servers'])
        flat['registrar_name'] =                 w['registrar']['name']
        flat['registrar_abuse_contact_phone'] =  w['registrar']['abuse_contact_phone']
        flat['registrar_abuse_contact_email'] =  w['registrar']['abuse_contact_email']
        flat['registrar_iana_id'] =              w['registrar']['iana_id']
        flat['registrar_url'] =                  w['registrar']['url']
        flat['registrar_whois_server'] =         w['registrar']['whois_server']
        flat['registrant_name'] =                w['contacts']['registrant']['name']
        flat['registrant_email'] =               w['contacts']['registrant']['email']
        flat['registrant_org'] =                 w['contacts']['registrant']['org']
        flat['registrant_street'] =              ' '.join(w['contacts']['registrant']['street'])
        flat['registrant_city'] =                w['contacts']['registrant']['city']
        flat['registrant_state'] =               w['contacts']['registrant']['state']
        flat['registrant_postal'] =              w['contacts']['registrant']['postal']
        flat['registrant_country'] =             w['contacts']['registrant']['country']
        flat['registrant_phone'] =               w['contacts']['registrant']['phone']
        flat['registrant_fax'] =                 w['contacts']['registrant']['fax']
        flat['admin_name'] =                     w['contacts']['admin']['name']
        flat['admin_email'] =                    w['contacts']['admin']['email']
        flat['admin_org'] =                      w['contacts']['admin']['org']
        flat['admin_street'] =                   ' '.join(w['contacts']['admin']['street'])
        flat['admin_city'] =                     w['contacts']['admin']['city']
        flat['admin_state'] =                    w['contacts']['admin']['state']
        flat['admin_postal'] =                   w['contacts']['admin']['postal']
        flat['admin_country'] =                  w['contacts']['admin']['country']
        flat['admin_phone'] =                    w['contacts']['admin']['phone']
        flat['admin_fax'] =                      w['contacts']['admin']['fax']
        flat['tech_name'] =                      w['contacts']['tech']['name']
        flat['tech_email'] =                     w['contacts']['tech']['email']
        flat['tech_org'] =                       w['contacts']['tech']['org']
        flat['tech_street'] =                    ' '.join(w['contacts']['tech']['street'])
        flat['tech_city'] =                      w['contacts']['tech']['city']
        flat['tech_state'] =                     w['contacts']['tech']['state']
        flat['tech_postal'] =                    w['contacts']['tech']['postal']
        flat['tech_country'] =                   w['contacts']['tech']['country']
        flat['tech_phone'] =                     w['contacts']['tech']['phone']
        flat['tech_fax'] =                       w['contacts']['tech']['fax']
        flat['billing_name'] =                   w['contacts']['billing']['name']
        flat['billing_email'] =                  w['contacts']['billing']['email']
        flat['billing_org'] =                    w['contacts']['billing']['org']
        flat['billing_street'] =                 ' '.join(w['contacts']['billing']['street'])
        flat['billing_city'] =                   w['contacts']['billing']['city']
        flat['billing_state'] =                  w['contacts']['billing']['state']
        flat['billing_postal'] =                 w['contacts']['billing']['postal']
        flat['billing_country'] =                w['contacts']['billing']['country']
        flat['billing_phone'] =                  w['contacts']['billing']['phone']
        flat['billing_fax'] =                    w['contacts']['billing']['fax']
        return flat
def flatten_parsed_whois ( self , response ) : data = response . json ( ) try : w = data [ 'response' ] [ 'parsed_whois' ] except KeyError : return { } flat = OrderedDict ( ) flat [ 'domain' ] = w [ 'domain' ] flat [ 'created_date' ] = w [ 'created_date' ] flat [ 'updated_date' ] = w [ 'updated_date' ] flat [ 'expired_date' ] = w [ 'expired_date' ] flat [ 'statuses' ] = ' | ' . join ( w [ 'statuses' ] ) flat [ 'name_servers' ] = ' | ' . join ( w [ 'name_servers' ] ) flat [ 'registrar_name' ] = w [ 'registrar' ] [ 'name' ] flat [ 'registrar_abuse_contact_phone' ] = w [ 'registrar' ] [ 'abuse_contact_phone' ] flat [ 'registrar_abuse_contact_email' ] = w [ 'registrar' ] [ 'abuse_contact_email' ] flat [ 'registrar_iana_id' ] = w [ 'registrar' ] [ 'iana_id' ] flat [ 'registrar_url' ] = w [ 'registrar' ] [ 'url' ] flat [ 'registrar_whois_server' ] = w [ 'registrar' ] [ 'whois_server' ] flat [ 'registrant_name' ] = w [ 'contacts' ] [ 'registrant' ] [ 'name' ] flat [ 'registrant_email' ] = w [ 'contacts' ] [ 'registrant' ] [ 'email' ] flat [ 'registrant_org' ] = w [ 'contacts' ] [ 'registrant' ] [ 'org' ] flat [ 'registrant_street' ] = ' ' . join ( w [ 'contacts' ] [ 'registrant' ] [ 'street' ] ) flat [ 'registrant_city' ] = w [ 'contacts' ] [ 'registrant' ] [ 'city' ] flat [ 'registrant_state' ] = w [ 'contacts' ] [ 'registrant' ] [ 'state' ] flat [ 'registrant_postal' ] = w [ 'contacts' ] [ 'registrant' ] [ 'postal' ] flat [ 'registrant_country' ] = w [ 'contacts' ] [ 'registrant' ] [ 'country' ] flat [ 'registrant_phone' ] = w [ 'contacts' ] [ 'registrant' ] [ 'phone' ] flat [ 'registrant_fax' ] = w [ 'contacts' ] [ 'registrant' ] [ 'fax' ] flat [ 'admin_name' ] = w [ 'contacts' ] [ 'admin' ] [ 'name' ] flat [ 'admin_email' ] = w [ 'contacts' ] [ 'admin' ] [ 'email' ] flat [ 'admin_org' ] = w [ 'contacts' ] [ 'admin' ] [ 'org' ] flat [ 'admin_street' ] = ' ' . join ( w [ 'contacts' ] [ 'admin' ] [ 'street' ] ) flat [ 'admin_city' ] = w [ 'contacts' ] [ 'admin' ] [ 'city' ] flat [ 'admin_state' ] = w [ 'contacts' ] [ 'admin' ] [ 'state' ] flat [ 'admin_postal' ] = w [ 'contacts' ] [ 'admin' ] [ 'postal' ] flat [ 'admin_country' ] = w [ 'contacts' ] [ 'admin' ] [ 'country' ] flat [ 'admin_phone' ] = w [ 'contacts' ] [ 'admin' ] [ 'phone' ] flat [ 'admin_fax' ] = w [ 'contacts' ] [ 'admin' ] [ 'fax' ] flat [ 'tech_name' ] = w [ 'contacts' ] [ 'tech' ] [ 'name' ] flat [ 'tech_email' ] = w [ 'contacts' ] [ 'tech' ] [ 'email' ] flat [ 'tech_org' ] = w [ 'contacts' ] [ 'tech' ] [ 'org' ] flat [ 'tech_street' ] = ' ' . join ( w [ 'contacts' ] [ 'tech' ] [ 'street' ] ) flat [ 'tech_city' ] = w [ 'contacts' ] [ 'tech' ] [ 'city' ] flat [ 'tech_state' ] = w [ 'contacts' ] [ 'tech' ] [ 'state' ] flat [ 'tech_postal' ] = w [ 'contacts' ] [ 'tech' ] [ 'postal' ] flat [ 'tech_country' ] = w [ 'contacts' ] [ 'tech' ] [ 'country' ] flat [ 'tech_phone' ] = w [ 'contacts' ] [ 'tech' ] [ 'phone' ] flat [ 'tech_fax' ] = w [ 'contacts' ] [ 'tech' ] [ 'fax' ] flat [ 'billing_name' ] = w [ 'contacts' ] [ 'billing' ] [ 'name' ] flat [ 'billing_email' ] = w [ 'contacts' ] [ 'billing' ] [ 'email' ] flat [ 'billing_org' ] = w [ 'contacts' ] [ 'billing' ] [ 'org' ] flat [ 'billing_street' ] = ' ' . join ( w [ 'contacts' ] [ 'billing' ] [ 'street' ] ) flat [ 'billing_city' ] = w [ 'contacts' ] [ 'billing' ] [ 'city' ] flat [ 'billing_state' ] = w [ 'contacts' ] [ 'billing' ] [ 'state' ] flat [ 'billing_postal' ] = w [ 'contacts' ] [ 'billing' ] [ 'postal' ] flat [ 'billing_country' ] = w [ 'contacts' ] [ 'billing' ] [ 'country' ] flat [ 'billing_phone' ] = w [ 'contacts' ] [ 'billing' ] [ 'phone' ] flat [ 'billing_fax' ] = w [ 'contacts' ] [ 'billing' ] [ 'fax' ] return flat