关于asp取网页信息并过滤html代码

 <!--#include file="conn/conn.asp"-->
 <%

 sqlm ="select fid from fid_table "
 set rs =server.CreateObject("adodb.Recordset")
  rs.open sqlm ,conn,1,1
  'if rs.eof then
  'response.Write("数据不存在!")
  'else
   if rs("fid")< 1707 then
      response.Write("更新了"&rs("fid")&"次数据")
     sqk ="update fid_table set fid =fid+1"
  conn.execute(sqk)
  Response.Write "<script language='javascript'>setTimeout('this.location.reload()',5000);</script>"
   else
      response.Write("数据已经更新完毕")
   end if
%>
 <%
Function FilterHTML(strToFilter)
  Dim strTemp
  strTemp = strToFilter
  While Instr(1, strTemp,"<")>0 and Instr(1,strTemp,">")>0
    strTemp = Left(strTemp, Instr(1, strTemp,"<")-1)+ Right(strTemp,Len(strTemp) -Instr(1,strTemp,">"))
  WEnd
  FilterHTML = strTemp
End Function
function shift(str)
  str =left(str,5000)
  str =right(str,len(str) - 200)
  str =replace(str,chr(32),"")
    str =replace(str,chr(13)&chr(10)&chr(13)&chr(10)&chr(13)&chr(10),chr(13)&chr(10))
 str =replace(str,chr(13)&chr(10)&chr(13)&chr(10)&chr(13)&chr(10)&chr(13)&chr(10),chr(13)&chr(10))
 str =replace(str,chr(13)&chr(10)&chr(13)&chr(10),chr(13)&chr(10))
  str =replace(str,chr(13)&chr(10)&chr(13)&chr(10)&chr(13)&chr(10)&chr(13)&chr(10)&chr(13)&chr(10),chr(13)&chr(10))
  str =replace(str,chr(13)&chr(10),",")
  str =replace(str,",,",",")
  shift =str
end function
 'response.Write(path)
 
Set fso = Server.CreateObject("Scripting.FileSystemObject")
'path = "c: emp est.txt"
'ForReading = 1
'ForWriting = 2
'ForAppending = 3

set file = fso.OpenTextFile ("e:web/tel.txt",8,True)
'response.Write(FilterHTML(strm))
' response.Write(left(strm,10))
       ServerURL="http://www.cn1860.net/sms/search1.asp?province=&city=&page=1"'&rs("fid")
   ' ServerURL="http://www.cn1860.net/sms/search1.asp"
       Set Mail1 = Server.CreateObject("CDO.Message")
        Mail1.CreateMHTMLBody ServerURL,31
        AA=Mail1.HTMLBody
       Set Mail1 = Nothing
'response.Write(trim(file_html(shift(AA))))
' create the fso object
dateHtml =right(shift(FilterHTML(aa)),len(shift(FilterHTML(aa))) -1)
asm =split(dateHtml,",")
sum_ = ubound(asm,1) + 1
'response.Write(UBound(asm,1))
response.Write(sum_ & "<br/>")
i=9
for i=0 to sum_ -1  step 5
on error resume next
if asm(i) <>"" then
if err.number <> 0 then
 response.Write(i)
 exit for
end if

on error goto 0

if i + 4 >sum_ then
exit for
else
'response.Write(i & "<br/>")
'response.Write((i*5+1) &"<br/>")
if isnumeric(trim(asm(i+1))) and isnumeric(trim(asm(i))) then
  'Option Explicit
  On Error Resume Next
   'response.Write("Message")
  sql="insert into MobileDB(num,Area,City,Tsype)values('"&asm(i+1)&"','"&asm(i+2)&"','"&asm(i+3)&"','"&asm(i+4)&"')"
  conn.Execute(sql)
 If Err.Number <> 0 then
  Err.Clear
    Err.Raise vbObjectError

End If
end if

'response.Write(asm(i))
 end if
end if
next
'tam = split(trim(file_html(shift(AA))),"""")
'num=(UBound(tam ,1))
' i=0
' while tam(i)<>""
 ' response.Write(tam(i))
  ' i=i+1
' wend
'for i=0 to num
'response.Write(tam(i))
'next


file.write(date()&"&nbsp;"&time()&"第"&rs("fid")&"次:Erro:"&err.number) & vbcrlf

file.close
set file = nothing
set fso = nothing
rs.close
set rs =nothing
conn.close
set conn =nothing

%>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值