![]() |
中国DOS联盟-- 联合DOS 推动DOS 发展DOS --联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum |
| 游客 | 登录 | 注册 | 会员 | 搜索 | 中国DOS联盟 |
|
中国DOS联盟论坛 现在时间是 2026-08-11 00:10 |
共 47,811 主题排行 / 349,897 发帖 / 今日 0 篇 / 48,256 会员排行 |
| DOS批处理 & 脚本技术(批处理室) » 求教:已写一bat檔利用wget抓出某网页原始檔 |
| 可打印版本 1,094 / 13 |
| 第1楼 denis | 发表于 2008-12-18 12:16 |
| 新手上路 发帖 9 积分 10 | |
|
求教:已写一bat檔利用wget抓出某网页原始檔 求教:已写一bat檔利用wget抓出某网页原始檔于code.txt,但只要某”字符串”(如:所有的”yahoo”)填入于g.txt
该如编写?~谢谢?!! @echo off wget -q -O code.txt tw.dictionary.yahoo.com/ for /l %%i in (1,1,4) do echo %%i>nul cls title监控处理程序 ::有问题的写法;请各先进帮忙修正谢谢 for /f "tokens=* delims=*" %%a in ('FINDSTR "yahoo" code.txt') do (echo %%a >>g.txt) pause |
|
| 第2楼 yishanju | 发表于 2008-12-18 12:55 |
| 银牌会员 发帖 1,357 积分 1,488 | |
|
WGET 好像不能提交表单,
改用CURL 试试 CURL 功能上貌似更加强大 |
|
| 第3楼 denis | 发表于 2008-12-18 13:06 |
| 新手上路 发帖 9 积分 10 | |
|
我要问的重点不是wget的使用;而是在code.txt内已有该网页之原始檔存在,但为不规则排列
内有html卷标也有标点符号也有空格;但我只要将内文字符串所有的”yahoo”取出于g.txt;不知单用DOS批次作的到吗?谢谢!! |
|
| 第4楼 HAT | 发表于 2008-12-18 13:14 |
| 版主 发帖 5,017 积分 9,023 | |
|
code.txt的内容贴出来
并指明你要提取哪些字符串 |
|
| 第5楼 denis | 发表于 2008-12-18 13:35 |
| 新手上路 发帖 9 积分 10 | |
|
code.txt的内容已上传
希望g.txt的内容为(有几个文字yahoo就印几行yahoo)如下: yahoo yahoo yahoo |
|
| 第6楼 denis | 发表于 2008-12-18 13:41 |
| 新手上路 发帖 9 积分 10 | |
| 第7楼 clian76 | 发表于 2008-12-18 14:20 |
| 中级用户 发帖 162 积分 363 | |
|
可以不用第三方工具的,用VBS直接取得网页源码或页面。再查找。用VBS看网页源码的代码搜索下坛子里有。
|
|
| 第8楼 denis | 发表于 2008-12-18 16:26 |
| 新手上路 发帖 9 积分 10 | |
|
我再把我的问题说明一遍好了
现在有txt里面如下 <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <title>Yahoo!奇摩字典</title> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <link href="http://l.yimg.com/tw.yimg.com/i/tw/dictionary/i7/dic.css?v=20071116a" rel="stylesheet" type="text/css"> </head> <!-- SpaceID=0 robot --> <!-- end header.inc --> <body> <div id="maincol"> <div id="yhtw_masthead"> <div class="mhlogo"> <a href="/"><img src="http://tw.yimg.com/i/tw/dictionary/masthead_logo.gif" alt="Yahoo!奇摩字典" /></a> </div> <div class="mhsch"> <form action="http://tw.rd.yahoo.com/referurl/srch/search/dictionary/*http://tw.search.yahoo.com/search" target="_top"> <input type="hidden" name="fr" value="ush_dict"> <input type="hidden" name="ei" value="UTF-8"> <p> <label class="t"><input type="text" name="p" /></label> <label class="s"><input type="submit" value="搜寻网页" /></label> </p> <div> <a href="/">服务首页</a><b>|</b><a href="http://tw.help.cc.yahoo.com/cp_info.html?product=dictionary">服务说明等等. 我想生成一个txt如下(将上述内码里有”yahoo”取出填入) yahoo yahoo yahoo 等. 老大帮帮忙 |
|
| 第9楼 ily2013 | 发表于 2008-12-18 17:33 |
| 中级用户 发帖 83 积分 247 | |
|
区分大小写吗?不太明白生成这样一个文件有什么用,想知道^_^
sed "s/yahoo/\n&\n/g" test.txt|sed -n "/yahoo/p" 希望我理解的没错 |
|
| 第10楼 dwj61909 | 发表于 2008-12-18 18:23 |
| 新手上路 发帖 10 积分 18 | |
|
来个gawk的
[ Last edited by dwj61909 on 2008-12-18 at 18:25 ] |
|
| 第11楼 denis | 发表于 2008-12-18 19:53 |
| 新手上路 发帖 9 积分 10 | |
|
呀!顿时开悟不少~
其实只是把yahoo的网页拿来当测试用…. 真正目的为要监控一系统网站;若原始码内有出现(Tier1)~(Ter4)就代表有异常…就必须对该系统作处理及通知负责人 若通知后该网页则会有”已通知”字符串出现;但同一时间又有可能其它server出现异常那上述(Tier1)~(Ter4)字符串又会出现 故以字符串去做判别的话: 状况1:”Tier*” exist && “已通知” !exist echo alert(“msg”) 状况2: num(”Tier” exist) = num(“已通知” exist) do nothing 状况3: num(”Tier” exist) > num(“已通知” exist) alert(“msg”) 状况3: ”Tier*” !exist && “已通知” !exist do nothing 将上述状况写成一bat run at every 2 minute…. 感谢各位大大先进帮忙;获益良多…. |
|
| 第12楼 ngd | 发表于 2008-12-19 11:55 |
| 中级用户 发帖 108 积分 312 | |
Originally posted by yishanju at 2008-12-18 12:55: wget和curl都能提交表单 记得保存cookie 以登录cn-dos为例: curl -c cookie.txt -d "username=ngd&password=密码" http://www.cn-dos.net/forum/logging.php?action=login wget --save-cookies=cookie.txt --post-data="username=ngd&password=密码" http://www.cn-dos.net/forum/logging.php?action=login |
|
| 第13楼 denis | 发表于 2008-12-22 09:42 |
| 新手上路 发帖 9 积分 10 | |
Originally posted by dwj61909 at 2008-12-18 06:23 PM: 上述可改成gawk "/已通知/ {printf \"yahoo\r\n\"}" code.txt>g.txt吗? 即pattern型式可以为中文字符串吗? |
|
| 第14楼 dxka8cww | 发表于 2008-12-22 09:47 |
| 新手上路 发帖 4 积分 5 | |
|
学习了`哈哈
|
|
|
[ 联系联盟系统管理团队 -
中国DOS联盟 -
标准版 ] Sponsored by ifanr Inc | © 2001–2023 |