]" Set matches=oreg.Execute(txtbody" />
首页 » ASP代码 » VBS查询网页所有链接用正则表达式

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

, , ,

转发到新浪微博 转发到新浪微博

目前这篇文章有8条评论(Rss)

  1. serivce | #1
    05/17/2012 at 04:03

    5wNHNp Great blog post.Really looking forward to read more. Much obliged.

  2. bookmarking | #2
    05/17/2012 at 06:04

    OaskYW Thanks-a-mundo for the blog post.Thanks Again. Really Great.

  3. social | #3
    05/17/2012 at 06:44

    5wKIYC wow, awesome article post.Really thank you!

我要评论