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

2016-01-29 19:38 180 1 收藏

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

【 tulaoshi.com - ASP 】

       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>
  

 

来源:https://www.tulaoshi.com/n/20160129/1509848.html

延伸阅读
标签: ASP
  <!--checkbag.asp-- <!--shoppingcart page-- <%       response.expires = 0     response.expiresabsolute = Now() - 1     response.addHeader "pragma","no-cache"     response.addHeader "cache...
标签: ASP
             <html>    <head>    <title>Confirmation </title>    <body>    <%       Set JMail = Server.CreateObject("JMail.SMTPMail")       ' ...
标签: Web开发
使用浏览器的内部对象系统, 可实现与HTML文档进行交互。它的作用是将相关元素组织包装起来,提供给程序设计人员使用,从而减轻编程人的劳动,提高设计Web页面的能力。 三、范例 例1:下面我们通过一个例子来说明文档对象的综合应用。输出结果见图6-2所示。 Test6_2.htm html head /HEAD BOdy Form Name="mytable" 请输入...
标签: Web开发
由于平时使用的网页文件基本上都是gb2312编码方式,如果通过xmlhttp控件读取的话,肯定会出现乱码问题,但是要把所有文件都改成utf-8编码,操作上比较麻烦。经过反复比较,我找到了相对实用的解决方法。 ff提供了overrideMimeType方法,可以指定返回值的编码,所以解决起来比较简单,只要把这个方法指向gb2312就可以了。对于IE,可以用vbs...
标签: Web开发
 1        Function RemoveHTML()Function RemoveHTML(strhtml)  2            if strhtml"" then  3                 dim s_str as str...

经验教程

805

收藏

41
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部