0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Julia: Yahoo 郵便番号検索API の使い方

Posted at

参考ページ
郵便番号検索API

get_address.jl
#! /usr/bin/julia
#
#	get_address.jl
#
#						Jul/31/2022
# --------------------------------------------------------------------
import Pkg; Pkg.add("HTTP")
using HTTP
using JSON
using DotEnv
# --------------------------------------------------------------------
println(stderr,"*** 開始 ***")
#
code_zip = ARGS[1]
println(code_zip)
#
DotEnv.config()
appid = ENV["APPID"]
#
url_base="https://map.yahooapis.jp/search/zip/V1/zipCodeSearch"
url = string(url_base , "?query=" , code_zip , "&output=json")
#
headers = Dict()
headers["Content-Type"] = "application/json"
headers["USER-AGENT"] = "Yahoo AppID: " * appid
#
rr = HTTP.request("GET", url,headers)
println(stderr,rr.status)

str_json=String(rr.body)
dict_aa = JSON.parse(str_json)
println(dict_aa["Feature"][1]["Property"]["Address"])
#
println(stderr,"*** 終了 ***")
# --------------------------------------------------------------------
.env
APPID = 'dj0zaiZpPW9NN3F****'

実行例

$ ./get_address.jl 131-8634
    Updating registry at `~/.julia/registries/General.toml`
   Resolving package versions...
  No Changes to `~/.julia/environments/v1.7/Project.toml`
  No Changes to `~/.julia/environments/v1.7/Manifest.toml`
*** 開始 ***
131-8634
200
東京都墨田区押上1-1-2東京スカイツリーイーストタワー11F
*** 終了 ***

次のバージョンで確認しました。

$ julia --version
julia version 1.7.3
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?