小偷程序2
程序员文章站
2024-01-12 08:20:04
复制代码 代码如下:<% dj54_path = "data/data.mdb" '数据库地址 set conn= ...
复制代码 代码如下:
<%
dj54_path = "data/data.mdb" '数据库地址
set conn= server.createobject("adodb.connection")
connstr = "provider=microsoft.jet.oledb.4.0;data source="&server.mappath(dj54_path)
conn.open connstr
function gethttppage(httpurl)
if isnull(httpurl)=true or httpurl="$false$" then
gethttppage="$false$"
exit function
end if
dim http
set http=server.createobject("msxml2.xmlhttp")
http.open "get",httpurl,false
http.send()
if http.readystate<>4 then
set http=nothing
gethttppage="$false$"
exit function
end if
gethttppage=bytestobstr(http.responsebody,"gb2312")
set http=nothing
if err.number<>0 then
err.clear
end if
end function
function bytestobstr(body,cset)
dim objstream
set objstream = server.createobject("adodb.stream")
objstream.type = 1
objstream.mode =3
objstream.open
objstream.write body
objstream.position = 0
objstream.type = 2
objstream.charset = cset
bytestobstr = objstream.readtext
objstream.close
set objstream = nothing
end function
function mymid(byval a_strstring,byval a_strpattern)
dim mm_objregexp
dim mm_strexecute
set mm_objregexp=new regexp
with mm_objregexp
.pattern=a_strpattern
.ignorecase=true
.global=false
set mm_strexecute=.execute(a_strstring)
if mm_strexecute.count<>0 then
mymid=mm_strexecute(0).submatches(0)
end if
end with
mymid=trim(mymid)
set mm_objregexp=nothing
end function
function reglistget(str,patrn,mysky)
set tempreg=new regexp
tempreg.ignorecase=false
tempreg.global=true
tempreg.pattern=patrn
set matches=tempreg.execute(str)
for each match in matches
content=content&match.value&mysky
next
reglistget=content
set matches=nothing
set tempreg=nothing
end function
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>(.+?)<script language=javascript src="&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/>"
set rs = server.createobject("adodb.recordset")
sql = "select * from sfdata"
rs.open sql,conn,1,3
for i =1 to ubound(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)&"")
if len(dj54_bt54_rsf(2)) < 16 then
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)
end if
response.write dj54_bt54_rsf(1) & "入库成功!<br/>"
next
response.write "全部入库完成"
%>
上一篇: 2018年湘潭大学程序设计竞赛G又见斐波那契(矩阵快速幂)
下一篇: Android的常用代码片段