复制代码代码如下:
<%
DJ54_path="data/data.mdb"'数据库地址
Setconn=Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;DataSource="&Server.MapPath(DJ54_path)
conn.Openconnstr
FunctionGetHttpPage(HttpUrl)
IfIsNull(HttpUrl)=TrueOrHttpUrl="$False$"Then
GetHttpPage="$False$"
ExitFunction
EndIf
DimHttp
SetHttp=server.createobject("MSXML2.XMLHTTP")
Http.open"GET",HttpUrl,False
Http.Send()
IfHttp.Readystate<>4then
SetHttp=Nothing
GetHttpPage="$False$"
Exitfunction
Endif
GetHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")
SetHttp=Nothing
IfErr.number<>0then
Err.Clear
EndIf
EndFunction
FunctionBytesToBstr(Body,Cset)
DimObjstream
SetObjstream=Server.CreateObject("adodb.stream")
objstream.Type=1
objstream.Mode=3
objstream.Open
objstream.Writebody
objstream.Position=0
objstream.Type=2
objstream.Charset=Cset
BytesToBstr=objstream.ReadText
objstream.Close
setobjstream=nothing
EndFunction
functionmymid(byvalA_strString,byvalA_strPattern)
dimMM_objRegexp
dimMM_strExecute
setMM_objRegexp=newregexp
withMM_objRegexp
.Pattern=A_strPattern
.IgnoreCase=True
.Global=false
setMM_strExecute=.Execute(A_strString)
ifMM_strExecute.count<>0then
mymid=MM_strExecute(0).SubMatches(0)
endif
endwith
mymid=trim(mymid)
setMM_objRegexp=nothing
endfunction
FunctionRegListGet(str,patrn,mysky)
settempReg=newRegExp
tempReg.IgnoreCase=false
tempReg.Global=true
tempReg.Pattern=patrn
setmatches=tempReg.execute(str)
foreachmatchinmatches
content=content&match.value&mysky
next
RegListGet=content
setmatches=nothing
settempReg=nothing
endFunction
DJ54_SF=GetHttpPage("http://www.haosf.com/")
DJ54_SF=replace(DJ54_SF,vbcrlf,"")
DJ54_SF=replace(DJ54_SF,chr(10),"")
DJ54_SF=trim(mymid(DJ54_SF,"zjkf.asp"&chr(34)&"></script>(.+?)<scriptlanguage=javascriptsrc="&chr(34)&"txtj2.asp"&chr(34)&">"))
DJ54_SF=RegListGet(DJ54_SF,"<script>o(.+?)</script>","BT54")
DJ54_SF=replace(DJ54_SF,"/","")
DJ54_BT54_SF=split(DJ54_SF,"BT54")
response.write"采集成功共采集当日"&Ubound(DJ54_BT54_SF)-1&"个SF<br/>"
setrs=server.createobject("adodb.recordset")
sql="select*fromsfdata"