复制代码 代码如下:
<%
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"
rs.opensql,conn,1,3
fori=1toUbound(DJ54_BT54_SF)-1
SF=mid(DJ54_BT54_SF(i),instr(DJ54_BT54_SF(i),""&chr(34)&"")+1,len(DJ54_BT54_SF(i))-48)
DJ54_BT54_RSF=split(SF,""&chr(34)&","&chr(34)&"")
iflen(DJ54_BT54_RSF(2))<16then
rs.addnew
SFtime=trim(mymid(DJ54_BT54_RSF(3),"日/(.+?)点"))
SFtime=replace(SFtime,"日/","")
SFtime=replace(SFtime,"点","")
rs("name")=DJ54_BT54_RSF(1)'名称
rs("ip")=DJ54_BT54_RSF(2)'IP
rs("sdate")=year(date)&"-"&month(date)&"-"&day(date)&""&SFtime&":00:00"
rs("Xingzhi")=DJ54_BT54_RSF(5)'性质
rs("email")=DJ54_BT54_RSF(6)'QQ
rs("homepage")=DJ54_BT54_RSF(0)'网
rs("addtime")=now()
rs("gameid")=28
rs("Ulock")=1
rs("service")=2
rs("addr")=DJ54_BT54_RSF(4)
endif
response.writeDJ54_BT54_RSF(1)&"入库成功!<br/>"
next
response.write"全部入库完成"
%>