Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maxmind parsing subdivision (state) wrong. #366

Open
yombo opened this issue Aug 7, 2018 · 0 comments
Open

Maxmind parsing subdivision (state) wrong. #366

yombo opened this issue Aug 7, 2018 · 0 comments

Comments

@yombo
Copy link

yombo commented Aug 7, 2018

Newbie to geocoder. But it appears Maxmind may have changed their API response concerning the state (subdivision). It looks like it was originally 'subdivision' and was changed a list under 'subdivisions'.

Here's the code that is parsing it now:

    @property
    def state(self):
        return self.raw.get('subdivision', {}).get('names', {}).get('en')

However, i think it should be something like this:

    @property
    def state(self):
        return self.raw.get('subdivisions', [{}])[0].get('names', {}).get('en')

Let me know if this seems correct and I'll submit a pull request.

Here's my raw output

m = geocoder.maxmind('108.88.147.139')
m.raw
{
  'location': {
    'accuracy_radius': '5',
    'latitude': 36.2558,
    'longitude': -86.6991,
    'metro_code': 659,
    'time_zone': 'America/Chicago'
  },
  'traits': {
    'autonomous_system_number': '7018',
    'autonomous_system_organization': 'AT&T Services, Inc.',
    'domain': 'sbcglobal.net',
    'isp': 'AT&T U-verse',
    'organization': 'AT&T U-verse',
    'ip_address': '108.88.147.139'
  },
  'city': {
    'geoname_id': 4639035,
    'names': {
      'en': 'Madison',
      'ru': 'Мадисон'
    }
  },
  'continent': {
    'code': 'NA',
    'geoname_id': 6255149,
    'names': {
      'ja': '北アメリカ',
      'pt-BR': 'América do Norte',
      'ru': 'Северная Америка',
      'zh-CN': '北美洲',
      'de': 'Nordamerika',
      'en': 'North America',
      'es': 'Norteamérica',
      'fr': 'Amérique du Nord'
    }
  },
  'country': {
    'iso_code': 'US',
    'geoname_id': 6252001,
    'names': {
      'zh-CN': '美国',
      'de': 'USA',
      'en': 'United States',
      'es': 'Estados Unidos',
      'fr': 'États-Unis',
      'ja': 'アメリカ合衆国',
      'pt-BR': 'Estados Unidos',
      'ru': 'США'
    }
  },
  'postal': {
    'code': '37115'
  },
  'registered_country': {
    'iso_code': 'US',
    'geoname_id': 6252001,
    'names': {
      'ru': 'США',
      'zh-CN': '美国',
      'de': 'USA',
      'en': 'United States',
      'es': 'Estados Unidos',
      'fr': 'États-Unis',
      'ja': 'アメリカ合衆国',
      'pt-BR': 'Estados Unidos'
    }
  },
  'subdivisions': [{
    'iso_code': 'TN',
    'geoname_id': 4662168,
    'names': {
      'pt-BR': 'Tenessi',
      'ru': 'Теннесси',
      'zh-CN': '田纳西州',
      'en': 'Tennessee',
      'es': 'Tennessee',
      'fr': 'Tennessee',
      'ja': 'テネシー州'
    }
  }]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant