手机
当前位置:查字典教程网 >编程开发 >ASP教程 >XMLHTTP抓取远程数据的后期处理
XMLHTTP抓取远程数据的后期处理
摘要:其他调用示例:hehe=Hello("http://list.mp3.baidu.com/song/A.htm","","",".*()(....

<%

hehe=Hello("http://mmsg.qq.com/cgi-bin/gddylist?Type=13&Sort=1&Page=3","<html>","</html>",".*(<tdwidth=""35%""bgcolor=""#[dABCDE]{6}"">(.*)</td>)[.n]*","<fontstyle=""font-size:9pt;""color=blue>$2</font><br>")

response.Writehehe

FunctionHello(strUrl,strStart,strEnd,patrn,replStr)

Str=GetBody(strUrl)

Str=MyMid(Str,strStart,strEnd)

Str=ReplaceTest(patrn,replStr,Str)

Hello=Str

EndFunction

FunctionMyMid(Str,strstart,strend)

Ifstrstart=""Then

i=0

Else

i=InStr(Str,strstart)

EndIf

Ifstrend=""Then

j=Len(Str)

Else

j=InStr(i,Str,strend)

EndIf

MyMid=Mid(Str,i,j-i+1)

EndFunction

FunctionReplaceTest(patrn,replStr,str1)

DimregEx,match,matches

SetregEx=NewRegExp

regEx.Pattern=patrn

regEx.IgnoreCase=True

regEx.Global=True

Setmatches=regEx.Execute(str1)

ForEachmatchinmatches

ReplaceTest=ReplaceTest®Ex.Replace(Match.Value,replStr)

Next

EndFunction

FunctionGetBody(Url)

SetobjXML=createObject("Microsoft.XMLHTTP")

WithobjXML

.Open"Get",Url,False,"",""

.SEnd

GetBody=.ResponseBody

EndWith

GetBody=BytesToBstr(GetBody,"GB2312")

SetobjXML=Nothing

EndFunction

FunctionBytesToBstr(strBody,CodeBase)

SetobjStream=Server.createObject("Adodb.Stream")

WithobjStream

.Type=1

.Mode=3

.Open

.WritestrBody

.Position=0

.Type=2

.Charset=CodeBase

BytesToBstr=.ReadText

.Close

EndWith

SetobjStream=Nothing

EndFunction

%>

其他调用示例:

hehe=Hello("http://list.mp3.baidu.com/song/A.htm","<tablewidth=""90%""border=""0""align=""center""cellpadding=""3""cellspacing=""0""bgcolor=""#f5f5f5"">","<DIValign=center>",".*(<tdwidth=""20%""><ahref="".*.htm""target=_blank>)(.*)(</a></td>)[.n]*","<fontstyle=""font-size:9pt;""color=blue>$2</font><br>")

【XMLHTTP抓取远程数据的后期处理】相关文章:

ASP:使用数据绑定控件显示数据

在ASP中通过oo4o连接Oracle数据库的例子

ASP与PHP的不同之处

如何在ASP中使用数据库

asp实现批量录入数据的实现

[转]XMLHTTPRequest的属性和方法简介

asp实现sql的备份与恢复

asp中COM组件中如何连接数据库的代码

ASP小偷(远程数据获取)程序入门教程

获取远程flash并保存到本地

精品推荐
分类导航