Rosetta Code/Count examples: Difference between revisions
Content added Content deleted
(→{{header|UNIX Shell}}: Add implementation) |
|||
Line 3,037: | Line 3,037: | ||
API=$SITE/mw/api.php |
API=$SITE/mw/api.php |
||
PAGES=$SITE/mw/index.php |
PAGES=$SITE/mw/index.php |
||
⚫ | |||
query="$API?action=query" |
|||
query+='&cmlimit=500&format=json' |
|||
query+=$(printf '&%s' \ |
|||
list=categorymembers \ |
|||
⚫ | |||
cmlimit=500) |
|||
total=0 |
total=0 |
||
while read title; do |
while read title; do |
||
t=${title// /_} |
t=${title// /_} |
||
tasks=$(curl -s "$PAGES?title=$t&action=raw" \ |
tasks=$(curl -s "$PAGES?title=$t&action=raw" \ |
||
Line 3,046: | Line 3,051: | ||
printf '%s: %d examples.\n' "$title" "$tasks" |
printf '%s: %d examples.\n' "$title" "$tasks" |
||
let total+=tasks |
let total+=tasks |
||
done < <(curl -s "$query" | jq -r '.query.categorymembers[].title') |
done < <(curl -s "$query&format=json" | jq -r '.query.categorymembers[].title') |
||
printf '\nTotal: %d examples.\n' "$total"</lang> |
printf '\nTotal: %d examples.\n' "$total"</lang> |
||
=={{header|zkl}}== |
=={{header|zkl}}== |