Advertisement
lollo78

Script search-wiki

Jun 11th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.31 KB | None | 0 0
  1. #!/bin/bash
  2. lang=$(echo $1 | cut -f1 -d '-')
  3. text=$2
  4. query=${text// /_}
  5. json=$(curl -sS "https://$lang.wikipedia.org/w/api.php?action=opensearch&search=$query&limit=1&namespace=0&format=json")
  6. descrquote=$(echo $json | sed -r 's/([^,]*,){2}//' | cut -f1 -d ']')
  7. descr=${descrquote//\"/}
  8. echo "Msg:"${descr//[/}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement