I touched Python's Request module for the first time. ** Can I create a query from JSON **? !! It's convenient! Great! → Reproduced with Shortcuts: relaxed:
This time, the URL for extracting the id from the Apple Music URL and requesting it to the iTunes Search API Is generated. ![079E3100-6A2E-40CC-9328-D34267E2BF38.jpeg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561438/42b96181-0db6-e9e0-57a9-d50df4d789ac .jpeg)
Specify to get the query with [Get URL component]
.
ʻI = 40284574` is output.
出力するURLのクエリーを
I want to set country = jp & lang = ja_jp & id = 40284574
, so enter the value that matches it.
This variable * i * is the magic variable output from the [Get component of URL]
above. Like the GIF below
dictionary
This action allows you to convert ** ʻi = 40284574
to{"i": "40284574"}
and treat it as the value of the key ʻi`. ** (Very convenient)
By the way, if you try to do the same without using this tech, it will increase by 2 actions (see the image below). It is troublesome, so I strongly recommend using the above technique.
Put the [dictionary]
keys (country
, lang
, ʻid) in
[repeat each item]to pair with the corresponding value. Using the technique above, treat the magic variables in the dictionary as a list (array) of keys. ![7D92D38F-9251-4B78-8026-FD98D199981B.gif](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561438/40776e22-3086-bff5-e5b6-1abef73cee05.gif) Output a list by connecting keys and values with'=' in
[Repeat each item]. We've combined this list with
[Merge Text]` using'&' and plunged into the query part of the URL.
Recommended Posts