The mirror URLs in the page are marked up as <strong>
, so you can scrape the page to get the top recommendation like this:
curl 'https://www.apache.org/dyn/closer.cgi' |
grep -o '<strong>[^<]*</strong>' |
sed 's/<[^>]*>//g' |
head -1
Additionally, closer.cgi
supports an ?as_json=1
query parameter to provide the same information as JSON. The result has a key of preferred
for the closest mirror, as well as http
for the alternatives.