Skip to content

Instantly share code, notes, and snippets.

@jorpic
Created June 23, 2015 17:35
Show Gist options
  • Save jorpic/6ac252b5ef3025b77bfc to your computer and use it in GitHub Desktop.
Save jorpic/6ac252b5ef3025b77bfc to your computer and use it in GitHub Desktop.
Get random fact from wikipedia
#!/bin/bash -e
API="http://en.wikipedia.org/w/api.php\
?action=query\
&prop=extracts\
&format=json\
&exsentences=2\
&explaintext=\
&exsectionformat=plain\
&rawcontinue=\
&generator=random\
&grnnamespace=0"
MSG=`curl -L -s "$API" | jq -r '.query.pages | to_entries[] | .value.extract'`
echo $MSG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment