标题: [网络连接] 批处理如何打开网站指定页面的链接 [打印本页]
作者: 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: 别被吞了):- 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:- location.href="http://www.bathome.net/forum-5-1.html"
复制代码
但可能因为此时新网址还没加载,所以无法读取 window.readystate,尝试设置 window.onload 也无效,不知怎么解决...
不过直接用外部脚本倒是好办:- Set ie = CreateObject("InternetExplorer.Application")
- Set WSHShell= CreateObject("Wscript.Shell")
-
- ie.Navigate "http://www.bathome.net/forum-5-1.html"
- ie.Visible = True
-
- Do Until ie.ReadyState = 4:Loop
-
- For Each a In ie.document.getelementsbytagname("a")
- If InStr(a,"thread-") Then WSHShell.Run a
- Next
- ie.Quit
复制代码
才发现 InternetExplorer.Application 没有 window 属性
而且用 InternetExplorer.Application 比较讨厌的是可能开启其他一些 ie 内核的浏览器,而且如果使用的是 ie9,需要事先存在 iexplore.exe 进程,否则报错
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |