A script for getting a Wikipedia article's See also
using MediaWiki Parsing API efficiently
title="$(echo "$1" | jq -Rr '@uri')"
theseealso="$(curl -s \
"https://en.wikipedia.org/w/api.php?action=parse&page=$title&prop=sections&format=json" |
jq -r '''.parse.sections | map(select(.line == "See also")) |
if isempty(.[]) then "nope" else .[0].index end ''')"
curl -s \
"https://en.wikipedia.org/w/api.php?action=parse&page=$title§ion=$theseealso&prop=links&format=json" |
jq -r '''.parse.links | map(select(.exists == "")) | .[] | .["*"] | @uri''' |
{ while IFS= read -r link
do
echo -e "${link//%/\\x}"
done
}