Skip to content

Instantly share code, notes, and snippets.

@jeffisabelle
Last active October 10, 2015 16:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffisabelle/3722627 to your computer and use it in GitHub Desktop.
Save jeffisabelle/3722627 to your computer and use it in GitHub Desktop.
translation from tureng
#!/bin/bash
url_encode() {
# http://www.commandlinefu.com/commands/view/4840/url-encode
# http://stackoverflow.com/questions/296536/urlencode-from-a-bash-script
echo -n "${@: -1}" | python2 -c "import urllib, sys; print urllib.quote(sys.stdin.readline())"
# echo "$@" | perl -MURI::Escape -ne 'chomp;print uri_escape($_),"\n"'
}
if [ $1 = "-v" ]; then
lynx -accept_all_cookies -dump -nonumbers "http://tureng.com/search/$(url_encode $@)" | grep -E '(^\s*Category\s*|>$)' --color=never | less
else
lynx -accept_all_cookies -dump -nonumbers "http://tureng.com/search/$(url_encode $@)" | grep -E '(^\s*Category\s*|>$)' --color=never | head -n 6
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment