Board logo

标题: [文本处理] [已解决]批处理如何批量打开网址? [打印本页]

作者: clemente123    时间: 2011-10-13 10:44     标题: [已解决]批处理如何批量打开网址?

TXT中很多网址,如下:

http://oekoportal.de/de/portal/search/branches/gesundheit+wellness+pflege/esoterik?pg=1
http://oekoportal.de/de/portal/search/branches/gesundheit+wellness+pflege/esoterik?pg=2
http://oekoportal.de/de/portal/search/branches/gesundheit+wellness+pflege/esoterik?pg=3
http://oekoportal.de/de/portal/search/branches/gesundheit+wellness+pflege/esoterik?pg=4
http://oekoportal.de/de/portal/search/branches/gesundheit+wellness+pflege/esoterik?
http://oekoportal.de/de/portal/search/branches/gesundheit+wellness+pflege/esoterik?pg=5
http://oekoportal.de/de/portal/search/branches/gesundheit+wellness+pflege/esoterik?pg=6
http://oekoportal.de/de/portal/search/branches/gesundheit+wellness+pflege/esoterik?pg=7
http://oekoportal.de/de/portal/search/branches/gesundheit+wellness+pflege/esoterik?pg=8
http://oekoportal.de/de/portal/search/branches/gesundheit+wellness+pflege/esoterik?pg=9
http://oekoportal.de/de/portal/search/branches/gesundheit+wellness+pflege/esoterik?pg=10
http://oekoportal.de/de/portal/search/branches/gesundheit+wellness+pflege/esoterik?pg=11
http://oekoportal.de/de/portal/search/branches/gesundheit+wellness+pflege/esoterik?pg=12
http://oekoportal.de/de/portal/search/branches/gesundheit+wellness+pflege/psychotherapie?
http://oekoportal.de/de/portal/search/branches/gesundheit+wellness+pflege/psychotherapie?pg=1
http://oekoportal.de/de/portal/search/branches/gesundheit+wellness+pflege/psychotherapie?pg=2
http://oekoportal.de/de/portal/search/branches/gesundheit+wellness+pflege/psychotherapie?pg=3
http://oekoportal.de/de/portal/search/branches/gesundheit+wellness+pflege/psychotherapie?pg=4
http://oekoportal.de/de/portal/search/branches/gesundheit+wellness+pflege/psychotherapie?pg=5
http://oekoportal.de/de/portal/search/branches/gesundheit+wellness+pflege/psychotherapie?pg=6
http://oekoportal.de/de/portal/search/branches/gesundheit+wellness+pflege/allergikerbedarf

注: 1. 要2个代码 : a.一次打开10个
                     b.一次打开100个,因为还有另外一堆网址需要一次打开100个,网址很相似

     2.网上有个前面加explorer的不行。

     3.我是外行,麻烦把使用方法也写下。

感谢各位高人伸出援助之手
作者: QIAOXINGXING    时间: 2011-10-13 11:41

本帖最后由 QIAOXINGXING 于 2011-10-13 11:56 编辑
  1. @echo off  &setlocal ENABLEDELAYEDEXPANSION
  2. set   a=0
  3. for /f "delims=" %%a in (test.txt) do (
  4.   set /a a+=1
  5.   start "" "%%a"
  6.   if "!a!"=="10" goto ll
  7. )
  8. :ll
  9. pause
复制代码
把要打开的网址复制到 test.txt
要打开100个把上面的 10 改成100 就行了。
我也是菜鸟,上面的代码我测试可以用。
作者: clemente123    时间: 2011-10-13 13:09

回复 2# QIAOXINGXING

只能打开前10个,点继续就关闭了!
作者: 601997526    时间: 2011-10-13 13:17

回复 3# clemente123
  1. @echo off&setlocal enabledelayedexpansion
  2. set 浏览器="C:\Program Files\Internet Explorer\IEXPLORE.EXE"
  3. set 数量=10
  4. for /f "delims=" %%i in (a.txt) do (start "" %浏览器% %%i
  5. set /a x+=1
  6. if !数量! equ !x! (pause&set x=0))
复制代码

作者: Fantasys    时间: 2011-10-13 14:33

好像2楼的方法就可以了。我想问问start后那双引号是什么用的。没有它还不行。
作者: clemente123    时间: 2011-10-13 15:26

回复 5# Fantasys


    我要的是循环的,就是线打开1-10,然后再11-20,然后再21-30 ,2楼的编码,开完10个之后,点继续,CMD就自动关闭了!
作者: QIAOXINGXING    时间: 2011-10-13 15:32

本帖最后由 QIAOXINGXING 于 2011-10-13 15:43 编辑
好像2楼的方法就可以了。我想问问start后那双引号是什么用的。没有它还不行。
Fantasys 发表于 2011-10-13 14:33



呵呵,刚学到的,见版主的新教学贴
http://www.bathome.net/thread-14341-1-1.html
作者: clemente123    时间: 2011-10-14 10:54

回复 7# QIAOXINGXING


    我要的是循环的,就是线打开1-10,然后再11-20,然后再21-30 ,2楼的编码,开完10个之后,点继续,CMD就自动关闭了!
作者: Hello123World    时间: 2011-10-14 16:06

  1. @echo off&Setlocal EnableDelayedExpansion
  2. For /f "delims=" %%i in (1.txt) do (
  3. Start "" "%%i"
  4. Set /a n+=1
  5. Set /a a=!n!%%10
  6. If !a!==0 pause
  7. )
  8. pause
复制代码

作者: zaixinxiangnian    时间: 2011-10-14 17:48

我发了一种笨方法,因为for里面的skip不支持变量书写(skip=!str!)
好像不加这个(C:\Program Files\Internet Explorer\IEXPLORE.EXE)的话会一闪而过
还有不明白IF和START那句为什么这样写不行
  1. if "!num!" leq "10" (start "" %a% "%%i")
复制代码
  1. @echo off
  2. setlocal enabledelayedexpansion
  3. set a="C:\Program Files\Internet Explorer\IEXPLORE.EXE"
  4. set num=0
  5. for /f "delims=" %%i in (3.txt) do (
  6.   echo %%i
  7.   set /a num+=1
  8.   set str+=1
  9.   echo !num!
  10.    start "" %a% "%%i"
  11.   if "!num!" equ "10" goto a
  12. )
  13. :a
  14. pause
  15. set num=0
  16. for /f "skip=10 delims=" %%i in (3.txt) do (
  17.   echo %%i
  18.   set /a num+=1
  19.   set str+=1
  20.   echo !num!
  21.    start "" %a% "%%i"
  22.   if "!num!" equ "10" goto b
  23. )
  24. :b
  25. pause
  26. set num=0
  27. for /f "skip=20 delims=" %%i in (3.txt) do (
  28.   echo %%i
  29.   set /a num+=1
  30.   set str+=1
  31.   echo !num!
  32.    start "" %a% "%%i"
  33.   if "!num!" equ "10" goto c
  34. )
  35. :c
  36. pause
  37. set num=0
  38. for /f "skip=30 delims=" %%i in (3.txt) do (
  39.   echo %%i
  40.   set /a num+=1
  41.   set str+=1
  42.   echo !num!
  43.    start "" %a% "%%i"
  44.   if "!num!" equ "10" goto d
  45. )
  46. :d
  47. pause
  48. set num=0
  49. for /f "skip=40 delims=" %%i in (3.txt) do (
  50.   echo %%i
  51.   set /a num+=1
  52.   set str+=1
  53.   echo !num!
  54.    start "" %a% "%%i"
  55.   if "!num!" equ "10" goto e
  56. )
  57. :e
  58. set num=0
  59. for /f "skip=50 delims=" %%i in (3.txt) do (
  60.   echo %%i
  61.   set /a num+=1
  62.   set str+=1
  63.   echo !num!
  64.    start "" %a% "%%i"
  65.   if "!num!" equ "10" goto f
  66. )
  67. :f
  68. pause
复制代码

作者: clemente123    时间: 2011-10-14 18:57

回复 9# Hello123World


    版主威武,麻烦再写个每次打开100的,谢谢
作者: clemente123    时间: 2011-10-14 18:58

回复 10# zaixinxiangnian


    没用你的,看看版主的,短小精悍!
作者: Hello123World    时间: 2011-10-14 19:16

回复 11# clemente123


    Set /a a=!n!%%10
把这句的10换成100就行了
作者: clemente123    时间: 2011-10-14 19:31

回复 13# Hello123World


    厉害,太厉害了!
作者: wh1234567    时间: 2012-5-22 02:04

我ie设置的是同一窗口里打开多个新选项卡的那种,运行

@echo off&Setlocal EnableDelayedExpansion
For /f "delims=" %%i in (1.txt) do (
        Start "" "%%i"
        Set /a n+=1
        Set /a a=!n!%%10
        If !a!==0 pause
        )
pause
提示无法打开是什么原因?
Windows 找不到文件 '*.*.*.*'。请确定文件名是否正确后,再试一次。要搜索文件,请单击「开始」按钮,然后单击“搜索”。
作者: wh1234567    时间: 2012-5-22 02:07

我不想在多个窗口里分别打开,只想在同一个窗口里多个新选项卡里分别打开的那种,不知道如何弄代码?
作者: wh1234567    时间: 2012-5-22 12:42

本帖最后由 wh1234567 于 2012-5-22 12:45 编辑

回复 2# QIAOXINGXING


    能不能修改成同时支持带有http://和不带有http://的网址?例如:
http://www.bathome.net/
http://www.2345.com
www.baidu.com
如果网址前缀无http://的话就提示无法打开
Windows 找不到文件 '这里是网址'。请确定文件名是否正确后,再试一次。要搜索文件,请单击「开始」按钮,然后单击“搜索”。
好像只支持带有http://的多个网址,希望修改成同时支持带有http://和不带有http://的网址
作者: QIAOXINGXING    时间: 2012-5-22 16:01

回复 17# wh1234567


    把其他浏览器设置为默认浏览器试试,我用的搜狗浏览器,www开头的也可以打开。




欢迎光临 批处理之家 (http://bathome.net./) Powered by Discuz! 7.2