Skip to content

Instantly share code, notes, and snippets.

@8q
Last active July 3, 2019 10:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 8q/9e7ad92a487754925c0fca780886a1e0 to your computer and use it in GitHub Desktop.
Save 8q/9e7ad92a487754925c0fca780886a1e0 to your computer and use it in GitHub Desktop.
$EKISPERT_KEY=駅すぱあとAPIのキー norikae 搭乗駅 降車駅 (出発時間:HHMM) ex)$norikae 新宿 大宮 1900
#!/bin/bash
if [ -z "$EKISPERT_KEY" ]; then
echo '$EKISPERT_KEY not set'
exit 1
fi
if [ $# -lt 2 ]; then
echo 'Usage: norikae from_station to_station (search_time:HHMM)'
exit 1
fi
FROM_STATION=$1
TO_STATION=$2
SEARCH_TIME=$3
URL="http://api.ekispert.jp/v1/json/search/course/light"
PARAMS=(
"key=$EKISPERT_KEY"
"from=$FROM_STATION"
"to=$TO_STATION"
"searchType=departure"
"plane=false"
"shinkansen=false"
"limitedExpress=false"
"redirect=false"
"contentsMode=pc"
)
if [ -n "$SEARCH_TIME" ]; then
PARAMS+=("time=$SEARCH_TIME")
fi
PARAM_STR=?$(IFS='&'; echo "${PARAMS[*]}")
open -a \
"/Applications/Google Chrome.app" \
$(curl -X GET -sS $URL$PARAM_STR |
jq ".ResultSet.ResourceURI" |
sed -E "s/\"//g")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment