LoginSignup
0
0

More than 3 years have passed since last update.

コマンドラインからINCI名を日本化粧品工業連合会のWEBで検索して成分表示名称などを取得する。

Last updated at Posted at 2020-10-15

コマンドラインからINCI名を日本化粧品工業連合会のWEBで検索して成分表示名称などを取得する。

概要

化粧品の輸入をする場合INCI名で書かれた成分リストを日本語のものに変換する作業が絶対に必要になる。日本化粧品工業連合会のWEBで検索してポチポチとやっていたのだが、めんどくさくなったので、将来の「表ごと変換」も視野に入れてまずはコマンドラインから検索できるようにする。

前提条件

  • mac
  • zsh

使い方

function(*後述)をコピペで貼り付けてエンター
その後

% search_from_jcia_by_inci [INCI_NAME]

% search_from_jcia_by_inci PG

結果

<?xml version="1.0" encoding="utf8"?>
<return_data>
  <rows>
    <row id="550009">
      <cell>
                550009  
            </cell>
      <cell>
                PG
            </cell>
      <cell>
                Propylene Glycol
            </cell>
      <cell>
                本品は、次の化学式で表される二価アルコールである。
            </cell>
      <cell>
                1
            </cell>
      <cell>
                2621
            </cell>
      <cell>
            </cell>
      <cell>
                1
            </cell>
    </row>
  </rows>
  <message>
</message>
  <debug>
</debug>
  <status>1</status>
  <page>0</page>
  <max>1</max>
  <limit>10</limit>
</return_data>

貼り付けるもの


function search_from_jcia_by_inci(){

  if test -z $1 ; then
    echo "usage  : search_from_jcia_by_inci [INCI_NAME]"
    echo "ex) search_from_jcia_by_inci BG"
  fi
  (
  PHPSESSID=$(curl 'https://www.jcia.org/user/business/ingredients/search' \
    -H 'Connection: keep-alive' \
    -H 'Accept: */*' \
    -H 'X-Requested-With: XMLHttpRequest' \
    -H 'sec-ch-ua-mobile: ?0' \
    -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
    -H 'Origin: https://www.jcia.org' \
    -H 'Sec-Fetch-Site: same-origin' \
    -H 'Sec-Fetch-Mode: cors' \
    -H 'Sec-Fetch-Dest: empty' \
    -H 'Referer: https://www.jcia.org/user/business/ingredients/namelist' \
    -H 'Accept-Language: ja,en-US;q=0.9,en;q=0.8' \
    --data-raw 'search%5Bfreeword%5D=@'$1 \
    --compressed -i | grep 'Set-Cookie: PHPSESSID=' | cut -d '='  -f2 | cut -d ';' -f1)

   curl 'https://www.jcia.org/user/business/ingredients/list/page/0' \
        -H 'Connection: keep-alive' \
        -H 'Accept: text/plain, */*; q=0.01' \
        -H 'sec-ch-ua-mobile: ?0' \
        -H 'X-Requested-With: XMLHttpRequest' \
        -H 'Sec-Fetch-Site: same-origin' \
        -H 'Sec-Fetch-Mode: cors' \
        -H 'Sec-Fetch-Dest: empty' \
        -H 'Referer: https://www.jcia.org/user/business/ingredients/namelist' \
        -H 'Accept-Language: ja,en-US;q=0.9,en;q=0.8' \
        -H 'Cookie: PHPSESSID='$PHPSESSID';' \
        --compressed | xmllint --encode utf8 --format -
    )
  }
0
0
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
0