免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1880 | 回复: 7

[已解決] 再一个问题...关于线上字典 [复制链接]

论坛徽章:
0
发表于 2008-11-04 23:43 |显示全部楼层
再一次需要大家帮忙了
我要做一个文字字典, 档案叫做 dict.sh

当输入 sh dict.sh keyword 的时候,
它会自动连到google字典 (http://www.google.com.tw/dictionary?hl=en)
去找keyword资料,然后把第一行的定义抓出来输出到屏幕.

请问这要怎么做呢?
我试了很久都没办法做出来...
在线等待救援, 谢谢大家!

[ 本帖最后由 crazyching84 于 2008-11-5 03:52 编辑 ]

论坛徽章:
0
发表于 2008-11-05 03:51 |显示全部楼层
自己解決了...呵呵
喜歡的朋友拿去用~

  1. #!/bin/sh
  2. curl -s "http://www.google.com.tw/dictionary?aq=f&langpair=en|en&q=$1&hl=en" | \
  3.         sed -n '/Web definitions/,$p' | \
  4.         sed -n '6p' | \
  5.         sed -e :a -e 's/<[^>]*>//g;/</N;//ba'
复制代码


用法是 sh dict.sh keyword

[ 本帖最后由 crazyching84 于 2008-11-5 03:52 编辑 ]

论坛徽章:
0
发表于 2008-11-05 10:19 |显示全部楼层
给LZ增增人气,其实curl还是挺有意思的.我还记得whois ip,第一次的那种feel至今还记得

论坛徽章:
0
发表于 2008-11-05 12:19 |显示全部楼层
为什么没有结果输出??

论坛徽章:
0
发表于 2008-11-05 13:53 |显示全部楼层
原帖由 smallstar001 于 2008-11-5 12:19 发表
为什么没有结果输出??


不太懂您的意思~
用法是 sh dict.sh keyword
范例:

[testpc@testpc] ~/temp> sh dict.sh sexy
voluptuously sensual in appearance or behavior ( informal )

[testpc@testpc] ~/temp> sh dict.sh sex
sexual activity: activities associated with sexual intercourse; "they had sex in the back seat"

[testpc@testpc] ~/temp> sh dict.sh cute
Common User Terminal Equipment - a computer system provided to airlines by the airport which allows airline staff to access their own computer .

主要就是把google字典里的第一个定义输出出来而已.

论坛徽章:
0
发表于 2008-11-05 16:44 |显示全部楼层
原帖由 crazyching84 于 2008-11-5 13:53 发表


不太懂您的意思~
用法是 sh dict.sh keyword
范例:

[testpc@testpc] ~/temp> sh dict.sh sexy
voluptuously sensual in appearance or behavior ( informal )

[testpc@testpc] ~/temp> sh dict.sh ...


[root@CCOSS_310968054 shl]# ./dict sex
[root@CCOSS_310968054 shl]# ./dict sexy
[root@CCOSS_310968054 shl]#
啥都没有

论坛徽章:
0
发表于 2008-11-05 17:06 |显示全部楼层
原帖由 smallstar001 于 2008-11-5 16:44 发表


[root@CCOSS_310968054 shl]# ./dict sex
[root@CCOSS_310968054 shl]# ./dict sexy
[root@CCOSS_310968054 shl]#
啥都没有


是不是因为环境的问题呢?
我是在freebsd底下执行的

我直接copy
  1. #!/bin/sh
  2. curl -s "http://www.google.com.tw/dictionary?aq=f&langpair=en|en&q=$1&hl=en" | \
  3.         sed -n '/Web definitions/,$p' | \
  4.         sed -n '6p' | \
  5.         sed -e :a -e 's/<[^>]*>//g;/</N;//ba'
复制代码


在另一台freebsd机器测试也是正常的~
麻烦老大再试试看!

[ 本帖最后由 crazyching84 于 2008-11-5 17:10 编辑 ]

论坛徽章:
0
发表于 2008-11-06 08:33 |显示全部楼层

回复 #7 crazyching84 的帖子

估计他没插网线吧~呵呵
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP