简体   繁体   English

nodejs-iso 3166-替代国家/地区名称

[英]nodejs - iso 3166 - Alternative countries names

I'm writing a program that extracts countries from https://restcountries.eu/ I'm using the data to save in my mongo DB and update it. 我正在编写一个从https://restcountries.eu/中提取国家/地区的程序,我正在使用将数据保存在mongo数据库中并进行更新的程序。 ofc, the data doesn't change too often, but this is for a decade forward. 当然,数据不会经常更改,但这已经是十年了。

const COUNTRIES_URL = 'https://restcountries.eu/rest/v2/all';
const axios = require('axios');

exports.httpCrawl = () => (
  axios.get(COUNTRIES_URL).then(response => (
    response.data.map(country => ({
      name: country.name,
      digits2: country.alpha2Code,
      digits3: country.alpha3Code,
      countryId: country.numericCode,
      flag: country.flag
    })))));

now when the data is in the DB, I want to use it to map other entities I'm getting from other APIs, for example, sports games. 现在,当数据在数据库中时,我想使用它来映射我从其他API(例如体育比赛)获得的其他实体。 but the games come with the country's alternative name (for example England instead of Great Britain). 但是游戏带有该国家的替代名称(例如,英格兰而不是英国)。

Is there a way to map the country's alternative names to the iso 3166 name/id? 有没有办法将国家的备用名称映射到iso 3166名称/ id?

您可以利用Google Places API之类的服务,这将使您能够根据备用名称或部分信息提取相关的国家/地区信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM