Rosetta Code/Count examples: Difference between revisions

→‎{{header|UNIX Shell}}: Add implementation
(→‎{{header|Python}}: Update to Python 3; correct URLs; include User-Agent that won't result in a 403 from the API.)
(→‎{{header|UNIX Shell}}: Add implementation)
Line 3,029:
2011-01-15 03:41:30: 455 Programing Tasks: 16009 solutions
</pre>
 
=={{header|UNIX Shell}}==
{{works with|Bourne Again Shell}}
{{trans|Python}}
<lang sh>#!/usr/bin/env bash
SITE=https://www.rosettacode.org
API=$SITE/mw/api.php
PAGES=$SITE/mw/index.php
query="$API?action=query&list=categorymembers&cmtitle=Category:Programming_Tasks"
query+='&cmlimit=500&format=json'
total=0
while read title; do
t=${title// /_}
tasks=$(curl -s "$PAGES?title=$t&action=raw" \
| grep -c '{{header|')
printf '%s: %d examples.\n' "$title" "$tasks"
let total+=tasks
done < <(curl -s "$query" | jq -r '.query.categorymembers[].title')
printf '\nTotal: %d examples.\n' "$total"</lang>
 
 
=={{header|zkl}}==
1,480

edits