[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[网络工具] 批处理在线学习英语

无聊时写的一个小工具,代码还是很繁杂。用到了外部工具curl.exe,测试成功率90+,出错原因可能是无此单词,或者文本提取错误。
直接运行,输入要查的单词,会输出单词的词性、释义、以及例句。
  1. @echo off&title English Online
  2. for %%a in (a n prep vt vi adv adj ad conj) do set %%a.=a
  3. for %%i in (a.[Z] vi.[W] vt.vi. n.[C]) do set "%%i=a"
  4. :loop
  5. cls&set "word="
  6. echo.&set/p word=   English Online:   
  7. for %%a in (on off) do if "%word%" equ "%%a" goto :next
  8. echo %word%|findstr/i "^[a-z]*$">nul||goto loop
  9. :next
  10. curl "http://www.baidu.com/baidu?ie=gb2312&cl=3&ct=1048576&word=%word%" -o tmp.txt
  11. cls&more +100 tmp.txt>temp.txt
  12. del tmp.txt&echo.&echo    [%word%]
  13. for /f "delims=" %%a in (temp.txt) do (
  14.      set "str=%%a"
  15.      setlocal enabledelayedexpansion
  16.      set "str=!str:*]=!"&set "str=!str:*]=!"
  17.      set "str=!str:</div><div class=!"&set "str=!str:pcixin>=!"
  18.      set "str=!str:pexplain>=!"&set "str=!str:peng><span id=!"
  19.      set "str=!str:dropdownid>=!"&set "str=!str:<font class=!"
  20.      set "str=!str:engi>=!"&set "str=!str:</font>=!"
  21.      set "str=!str:</span>=!"&set "str=!str:pchi><span id=!"
  22.      set "str=!str:</div><div =!"&set "str=!str:<==!"&set "str=!str:>==!"
  23.      set "str=!str:^)=!"&set "str=!str:^(=!"&set "str=!str:"=!"
  24.      call :lp "!str!"
  25.      endlocal
  26.      del temp.txt 2>nul&pause>nul&goto :loop
  27. )
  28. :lp
  29. for /f "tokens=1* delims==" %%a in ("%~1") do (
  30.      set "var=%%a"
  31.      if /i "!var!" equ "/body" echo.&echo    ERROR&goto :eof
  32.      if /i "!var:~,4!" equ "/div" goto :eof
  33.      if defined !var! echo.
  34.      for /l %%a in (0 1 9) do if "!var:~,1!" equ "%%a" echo.
  35.      echo    !var!
  36.      if "%%b" neq "" call :lp "%%b"
  37. )
  38. goto :eof
复制代码
第三方命令行工具curl.exe下载地址:
http://bbs.bathome.net/thread-3981-1-1.html
-------------------------------------------------------------------------------------------------------------------------------------
调用外部工具wfr.exe简化代码。使用wget.exe下载html网页代码。
添加了备份功能,会在D盘生成一个名为word的文件夹,里面存放查阅过的单词。
  1. @echo off
  2. if not exist d:\word\ md d:\word\
  3. :loop
  4. setlocal
  5. cls&echo.&echo.
  6. set/p word=  English online:
  7. if not defined word endlocal&goto loop
  8. if exist "d:\word\%word%.txt" type "d:\word\%word%.txt"&pause>nul&endlocal&goto loop
  9. (echo.&echo [%word%]&echo.)>"d:\word\%word%.txt"
  10. wget -O tmp.txt "http://www.baidu.com/baidu?ie=gb2312&cl=3&ct=1048576&word=%word%" -q
  11. title English online
  12. more +100 tmp.txt>tmp&move /y tmp tmp.txt
  13. wfr tmp.txt /rnnlic:"(以上结果.*|.*>\]</div>|<\/(font|div|span)>)" /t
  14. wfr tmp.txt /r:"(<div class=p(cixin|explain|eng|chi)>|<span id=dropdownid>|<(font class=engi|br)>)" /t
  15. type tmp.txt|wfr /r:"\d+\." /t:"\r\n\r\n\0"|wfr /r:"(([a-z]+|\a)(\.|\?))" /t:"\0\n"|wfr /r:"[A-Z]{1,}(\s|\a)+" /t:"\n\0">>"d:\word\%word%.txt"
  16. type "d:\word\%word%.txt"&del tmp.txt
  17. endlocal
  18. pause>nul
  19. goto loop
复制代码
第三方命令行工具wget.exe和wfr.exe下载地址:
http://bbs.bathome.net/thread-3981-1-1.html
3

评分人数

心绪平和,眼藏静谧。

看来pusofalse又研究了新领域了,呵呵,不过总觉得这种代码实际意义并不大,只是如何自动登录网页并进行搜索的方法值得借鉴。
***共同提高***

TOP

我觉得用google可能更好些
http://www.google.cn/language_tools?hl=zh-CN
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

下来试试!
值得学习啊

TOP

不行!!!!
测试不成功

TOP

回复 5楼 的帖子

请把出错信息贴上来
心绪平和,眼藏静谧。

TOP

回复 5楼 的帖子

Q: 为什么不行啊?
A: 去电线杆上找个老军医的手机,他是专治+包治这个的。如果治疗周期较长,建议列出你的测试环境、测试用例、出错信息,供大家帮助你解决问题。
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

回复 3楼 的帖子

google 百度 雅虎 这三家我都试验过了,curl在download的时候会保存为默认的编码格式,google是UTF-8,有用wfr进行编码转换,可是不管怎么转换都会丢弃信息,所以就用了百度,不知curl有无编码转换的功能。
心绪平和,眼藏静谧。

TOP

curl dict://dict.org/d:computer

TOP

借用est写过的下载网页vbs代码
感觉vbs功能还是很强大
  1. ::::::::::::::::::::::::::::::::::::::::::::::::
  2. ::[用法] 保存为dict.bat于当前路径后,命令行下格式: dict word
  3. ::::::::::::::::::::::::::::::::::::::::::::::::
  4. @echo off||author:plp626&<%~fs0 more +7>%tmp%\gtxt.vbs
  5. set "url=http://www.baidu.com/baidu?ie=gb2312&cl=3&ct=1048576&word=%1"
  6. cscript //NoLogo //e:vbscript %tmp%\gtxt.vbs "%url%"|more +4|findstr/v "Dr\.eye Baidu"|findstr .
  7. exit/b
  8. '         
  9. Set oDOM = WScript.GetObject(WScript.Arguments(0))
  10. do until oDOM.readyState = "complete"
  11. WScript.sleep 100
  12. loop
  13. WScript.echo oDOM.documentElement.outerText
复制代码
论坛把代码的空行竟然过滤了!!

[ 本帖最后由 plp626 于 2008-9-11 02:21 编辑 ]
3

评分人数

TOP

回复 9楼 的帖子

plp兄的代码果然高深,希望赐教一二。
心绪平和,眼藏静谧。

TOP

  1. 代码空行
  2. 测试
复制代码
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

回复 10楼 的帖子

加了code标签以后就不会过滤空行了吧,见12楼的测试。
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

其实只要在新的方面有点成绩了,慢慢弄嘛。找到更多得简便。

TOP

下了,很好用。
只能从good good study开始学起了,英语基本忘了。

TOP

返回列表