Board logo

标题: [网络连接] 批处理如何打开网站指定页面的链接 [打印本页]

作者: Rasm    时间: 2012-9-16 12:42     标题: 批处理如何打开网站指定页面的链接

比如我打开

http://www.bathome.net/forum-5-1.html

但是这个页面有很多的地址链接,我想打开地址中包含  “thread-”的链接,就自动打开,这个怎么实现啊??

也就是http://www.bathome.net/forum-5-1.html地址页面上的链接地址,有  “thread-”的链接,都自动打开
作者: CrLf    时间: 2012-9-16 14:41

在 ie 地址栏运行(注意头部的 vbscript: 别被吞了):
  1. vbscript:execute("for each a in document.getelementsbytagname(""a""):if instr(a,""thread-"") then window.open(a):end if:next")
复制代码

作者: Rasm    时间: 2012-9-16 20:14

回复 2# CrLf


    地址是哪个啊,这代码里咩写地址
作者: CrLf    时间: 2012-9-16 21:22

本帖最后由 CrLf 于 2012-9-16 21:36 编辑

打开网址可以用 location.href:
  1. location.href="http://www.bathome.net/forum-5-1.html"
复制代码
但可能因为此时新网址还没加载,所以无法读取 window.readystate,尝试设置 window.onload 也无效,不知怎么解决...

不过直接用外部脚本倒是好办:
  1. Set ie = CreateObject("InternetExplorer.Application")
  2. Set WSHShell= CreateObject("Wscript.Shell")
  3. ie.Navigate "http://www.bathome.net/forum-5-1.html"
  4. ie.Visible = True
  5. Do Until ie.ReadyState = 4:Loop
  6. For Each a In ie.document.getelementsbytagname("a")
  7. If InStr(a,"thread-") Then WSHShell.Run a
  8. Next
  9. ie.Quit
复制代码
才发现 InternetExplorer.Application 没有 window 属性
而且用 InternetExplorer.Application 比较讨厌的是可能开启其他一些 ie 内核的浏览器,而且如果使用的是 ie9,需要事先存在 iexplore.exe 进程,否则报错




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