LoginSignup
4
5

More than 5 years have passed since last update.

amazonの在庫情報をslackに投稿する

Posted at

amazonに「○○個在庫あり」のような情報が出ている場合下記のような感じで、雑に在庫情報を取得することができます。

#!/bin/bash
​
RAW_DATA=`curl http://www.amazon.co.jp/XXXXXX | grep 在庫あり`
SLACK_URL=https://hooks.slack.com/services/XXXXXXXXXXX

## 必要な部分のみを切り出す​
IFS='>'
set -- ${RAW_DATA}
TMP=$2
IFS='<'
set -- ${TMP}
NUM_CURRENT=$1

## 投稿する​
MSG="在庫は残り"${NUM_CURRENT}"です"
CONTENT='payload={"channel": "#hoge", "username": "bot", "text": "'${MSG}'", "icon_emoji": ":fuga:"}'
curl -X POST --data-urlencode ${CONTENT} ${SLACK_URL}
​
​```
4
5
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
4
5