Last active
July 3, 2019 10:11
-
-
Save 8q/9e7ad92a487754925c0fca780886a1e0 to your computer and use it in GitHub Desktop.
$EKISPERT_KEY=駅すぱあとAPIのキー norikae 搭乗駅 降車駅 (出発時間:HHMM) ex)$norikae 新宿 大宮 1900
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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