当前位置: 首页 > 图文教程 > 网络编程 > ASP > ASPHttp使用范例-远程读取别人的页面,并自动写入库

ASP
深入研究“用ASP上载文件”(一)
深入研究“用ASP上载文件”(二)
一个投票系统的源程序(coveryourasp.com)
一 些 ASP 小 源 程 序
用ASP制作个性化的调查板(附源程序)
一些源程序 - 获得文件大小和字符串处理
用ASP创建日志文件(附源程序)
在一个ASP页面停留的多少时间的程序
用VB6做一个简单的文件上传组件(一)
用VB6做一个简单的文件上传组件(二)
构建你的网站新闻自动发布系统之七
实 现 滚 动 新 闻
网上“店铺”DIY(1)
网上“店铺”DIY(2)
网上“店铺”DIY(3)
负载平衡环境下的ASP会话管理(1)
负载平衡环境下的ASP会话管理(2)
FrontPage创建HTML/ASP混合页面Ⅰ
FrontPage创建HTML/ASP混合页面Ⅱ
在ASP应用中验证用户身份(1)

ASPHttp使用范例-远程读取别人的页面,并自动写入库


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 73 ::
收藏到网摘: n/a

       ASPHttp使用范例-远程读取别人的页面,并自动写入库
  
  <html>
  <head>
  <title>AUTOGET</title>
  <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  </head>
  <body bgcolor="#FFFFFF">
  <%''on error resume next
   ''-----------建一个叫data的access表,字段(名称,来源,内容)
   Set conn = Server.CreateObject("ADODB.Connection")
   DBPath = Server.MapPath("data.mdb")
   conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DBPath &";"
   Set rs = Server.CreateObject("ADODB.Recordset")
   sql="select * from data"
   rs.open sql,conn,3,2
   ''以上完成表的打开
  
  Set HttpObj = Server.CreateObject("AspHTTP.Conn")
  dim fd
  fd = 111
  SearchFolder fd
  
  
  ''以下是过程
  Sub SearchFolder( fd )
  
  do while fd <> 500
  Response.Write fd
  HTTPObj.Url = "http://www.object.net/Read.asp?ArticleID="&fd
  HttpObj.RequestMethod = "GET"
  content = HTTPObj.GetURL
  
  ''取标题<img
   pos0=instr(1,content,"<img")
   pos1=instr(pos0,content,">")
   pos2=instr(pos1,content,"</td>")
   title=mid(content,pos1+1,pos2-pos1-1)
  
  ''来源<td>
   pos=instr(pos2,content,"<td>")
   pos1=instr(pos,content,"</td>")
   comefrom=mid(content,pos+4,pos1-pos-4)
  
   ''idno
  
   pos1=instr(1,content,"ArticleID")
   pos2=instr(pos1,content,">")
   idno=mid (content,pos1+10,pos2-pos1-10)
  
  ''内容
  
   pos1=instr(1,content,"<blockquote>")
   pos2=instr(pos1,content,"</blockquote>")
   content=mid (content,pos1+12,pos2-pos1-12)
  
  
  
  ''以下数据库操作:
  rs.addnew
   rs("名称")=title
   rs("来源")=comefrom
   rs("内容")=trim(content)
   rs("idno")=trim(idno)
  rs.update
  fd=fd + 1
  loop
  
  end sub
  ''过程结束
  
  Response.Write fd&"<br>"
  
  rs.close
  set conn=nothing
  set fs=nothing
  %>
  </body>
  </html>