XMLHTTP抓取远程数据的后期处理

发布时间:2022-04-17 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了XMLHTTP抓取远程数据的后期处理脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
<%&nbsp;
hehe = Hello("http://mmsg.QQ.COM/cgi-bin/gddylist?TyPE=13&amp;Sort=1&Page=3", "<htML>", "</html>", ".*(<td width=""35%"" bgcolor=""#[\dabcDE]{6}"">(.*)</td>)[.\n]*", "<font style=""font-Size:9pt;"" color=blue>$2</font><br>") 
response.WrITe hehe 

Function Hello(strUrl, strStart, strEnd, patrn, replStr) 
Str = GetBody(strUrl) 
Str = ;myMid(Str, strStart, strEnd) 
Str = Replacetest(patrn, replStr, Str) 
Hello = Str 
End Function 

Function MyMid(Str, strstart, strend) 
If strstart = "" Then 
i = 0 
Else 
i = InStr(Str, strstart) 
End If 
If strend = "" Then 
j = Len(Str) 
Else 
j = InStr(i, Str, strend) 
End If 
MyMid = Mid(Str, i, j - i + 1) 
End Function 

Function ReplaceTest(patrn, replStr, str1) 
Dim regEx, match, matches 
Set regEx = New RegExp 
regEx.Pattern = patrn 
regEx.IgnoreCase = True 
regEx.Global = True 
Set matches = regEx.Execute(str1) 
For each match in matches 
ReplaceTest = ReplaceTest&regEx.Replace(Match.Value, replStr) 
Next 
End Function 

Function GetBody(Url) 
Set objXML = createObject("Microsoft.XMLHTTP") 
With objXML 
.Open "Get", Url, False, "", "" 
.SEnd 
GetBody = .ResponseBody 
End With 
GetBody = BytesToBstr(GetBody, "GB2312") 
Set objXML = Nothing 
End Function 

Function BytesToBstr(strBody, CodeBase) 
Set objStream = Server.createObject("Adodb.Stream") 
With objStream 
.Type = 1 
.Mode = 3 
.Open 
.Write strBody 
.Position = 0 
.Type = 2 
.Charset = CodeBase 
BytesToBstr = .ReadText 
.Close 
End With 
Set objStream = Nothing 
End Function 
%> 
其他调用示例: 
hehe = Hello("http://list.mP3.baidu.com/song/A.htm", "<table width=""90%"" border=""0"" align=""center"" cellpadding=""3"" cellspacing=""0"" bgcolor=""#f5f5f5"" >", "<DIV align=center>", ".*(<td width=""20%""><a href="".*\.htm"" target=_blank>)(.*)(</a></td>)[.\n]*", "<font style=""font-size:9pt;"" color=blue>$2</font><br>")

脚本宝典总结

以上是脚本宝典为你收集整理的XMLHTTP抓取远程数据的后期处理全部内容,希望文章能够帮你解决XMLHTTP抓取远程数据的后期处理所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: