【发布时间】:2011-10-19 20:12:22
【问题描述】:
我需要输入一个链接列表,这些链接指向类似格式的页面,但内容不同,只有一个标签。
编辑
input.txt
/category/apples-and-oranges.html
/category/pineapples.html
/category/asparagus.html
/category/brussel-sprouts.html
/category/passion-fruit.html
假设涉及水果的页面有<h1>Fruit!</h1> 而非水果页面没有,但它们属于一个类别。该程序会检查这些对http://www.mysite.com 的扩展,然后创建一个新列表:
output.txt
/category/apples-and-oranges.html
/category/pineapples.html
/category/passion-fruit.html
这是我目前所得到的:
for /f %%A in (input.txt) DO (
for "tokens=1,2 delims=:" %%b in ('FINDSTR [/R] [/I] [/S] [/C:"<H1>.*Fruit!.*</H1>"] [[http://]www.mysite.com/%%A[*.html]]') DO (
echo ^<%%A> > <output.txt>
)
)
【问题讨论】:
-
你能给我们展示一个输入的实际例子和你想要达到的实际结果吗?
-
到目前为止您尝试了哪些方法以及遇到了什么问题?为了让您入门,请使用此提示...查看
FOR和FINDSTR命令并尝试此FOR /f "tokens=1,2 delims=:" %%a in ('FINDSTR /R /I /S "<H1>.*</H1>" *.htm') do ECHO ^<a href="%%a"^>%%b^</a^> -
谢谢@PA,但我仍然对你的意思有些困惑。如果我有任何问题,我会尝试并回复您。
-
我对其进行了编辑以显示我现在所处的位置......但我仍然无法运行它......
-
您的第二个
for是否缺少/f?
标签: batch-file