definr基于网页形式存放词条,写个script,抓数据很容易。
这个小脚本,尤其在命令行看E文man时很方便,term中新建一个tab,执行:
代码: 全选
definr word_unknown
特点:
1、我写的
2、基于网络
3、支持词组,不必加引号
4、抓网页源码于/tmp目录中,有提醒释放空间
5、重复查看一个词组不必重复抓服务器数据
代码: 全选
aBiNg:~ ¶ cat script/definr
#!/bin/bash
if [ x"$1" = x'' ]
then
read -p "input one word: " input
else
input=$*
fi
input=`echo $input | sed 's/ /%20/g'`
base_html="http://definr.com"
word_url="$base_html/$input"
word_file="/tmp/$input.html"
which html2text > /dev/null || sudo apt-get install html2text -y
function output {
html2text $1 | sed -n '9,$p' | more
}
if [ -f $word_file ]
then
output $word_file
else
wget -c -t 3 -q $word_url -O $word_file
output $word_file
fi
echo ''
html_counter=`ls /tmp/*.html | wc -l`
if [ $html_counter -gt 500 ]
then
echo 'WARNING:'
echo -e '\tMany definr-files fill in /tmp.'
echo -e '\tExecute "rm -f /tmp/*.html" in terminal to free spaces.'
fi