From a40e79917cf4fc322483ca449769adb25b30f7bd Mon Sep 17 00:00:00 2001 From: ars Date: Fri, 12 Jun 2020 21:44:14 +0100 Subject: Inital commit --- oedwordday.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 oedwordday.sh (limited to 'oedwordday.sh') diff --git a/oedwordday.sh b/oedwordday.sh new file mode 100755 index 0000000..33fcc44 --- /dev/null +++ b/oedwordday.sh @@ -0,0 +1,22 @@ +#!/bin/bash + + +word=$( curl --silent https://www.lexico.com/ | hxnormalize -x | hxselect -i "a.linkword" | grep -o '>.*<' | sed 's/[><]//g') +appId= +key= +language=en-gb +lemmasUrl=https://od-api.oxforddictionaries.com/api/v2/lemmas/$language/$word +OPTS='--silent -L -H "app_id: $appId" -H "app_key: $key"' + +entriesUrl=https://od-api.oxforddictionaries.com/api/v2/entries/$language/$word + +# get definition of headword +result=$(eval curl $OPTS $entriesUrl) +ret=$? +if [ "$ret" -ne 0 ] +then + echo "cURL error $ret when fetching." + exit +fi +definition=$(echo $result | jq '.results[0].lexicalEntries[0].entries[].senses[0].definitions') +echo $definition -- cgit v1.2.3