Last active
October 10, 2015 16:58
-
-
Save jeffisabelle/3722627 to your computer and use it in GitHub Desktop.
translation from tureng
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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