VBS查询网页所有链接用正则表达式
txtbody=gethttp("http://www.taobao.com/","") Set oreg=New RegExp oreg.Global=True : oreg.IgnoreCase=True oreg.Pattern= "href(\s*)=(\s*)(['""\s]*)([\w\:\-\%\/\.\?\=\&]+)(['""]*)[\s\>]" Set matches=oreg.Execute(txtbody) For Each match In matches 'WScript.Echo match.Submatches(3) '显示超链接地址 Next WScript.Echo "总共发现超级链接:" & matches.Count '写得粗糙但功能正常,本文只是演示正则使用方法和他的强大,如果仅是得到超链接数量,你可以在IE地址栏打开taobao网后输入 javascript:alert(document.all.tags("a").length) 也能达到同样效果 Function gethttp(urlstr,postdata) Set xmlhttp=CreateObject("microsoft.xmlhttp") xmlhttp.open "GET",urlstr,False xmlhttp.send postdata gethttp = xmlhttp.responsetext set xmlhttp=nothing End Function
上一篇: 用VB实现程序试用限制和过期限制
下一篇: 用VB给程序设置一个热键HOTKEY
目前这篇文章有8条评论(Rss)