Can you give me an example curl line for getting a summary of a given wikipedia page (say Scorpion) using Wikimedia REST API ?
UA='User-Agent: thy/1.0 mailto:[email protected]'
url=https://en.wikipedia.org
page=Scorpion
curl -sH "$UA" $url/api/rest_v1/page/summary/$page | jqCan I get a wikipedia list page (e.g. List_of_French_philosophers) as json ?
list=List_of_French_philosophersdata=(action parse page $list prop text format json formatversion 2)
jq='$ARGS.positional | _nwise(2) | "--data-urlencode \(first)=\(last)"'
args=$(jq "$jq" -nr --args ${data[@]})
curl -sH "$UA" -G $url/w/api.php $args > tmp/$list-1.jsjq='inputs | select(test("<li><a href=\"/wiki/"))'
jq+='| capture("href=..(?<href>[^\"]+).*title=.(?<title>[^\"]+)")'
< tmp/$list-1.js jq -r .parse.text | jq -Rn "$jq" > tmp/$list-2.jsjq='"curl -sLH \"\($ua)\" \($url)/api/rest_v1/page/summary/\($q)\((.href / "/")[-1])\($q)"'
mkdir -p tmp/$list/jpg
< tmp/$list-2.js jq "$jq" -r --arg ua "$UA" --arg url $url --arg q "'" > tmp/$list-3.sh< tmp/$list-3.sh bash | jq > tmp/$list-4.jsjq='select(has("thumbnail")) | "curl -s \(.thumbnail.source) -o \"\($list)/jpg/\(.titles.canonical).jpg\""'
< tmp/$list-4.js jq "$jq" --arg list tmp/$list -r > tmp/$list-5.sh< tmp/$list-5.sh bashjq='"# \(.title)", "", .extract, if has("thumbnail") then "", ".jpg)" else empty end, ""'
< tmp/$list-4.js jq "$jq" -r > tmp/$list/README.mdmkdir -p out
mv tmp/$list out