For my deployment automation needs, I would like to dynamically and programatically determine the closest Apache Software Foundation mirror since the servers are distributed
Here is an alternative using python:
curl -s 'https://www.apache.org/dyn/closer.cgi?as_json=1' \ | python -c "import sys, json; print json.load(sys.stdin)['preferred']"