linux社区爱心援助Linux认证系列教程业界动态站务新闻公司招聘网络学院网址大全LPI专题CISCO专题
设为首页
加入收藏
管理团队
JSP  
JAVA  
PERL  
 您的位置:首页 > 开发语言 > ASP >
栏目导栏
  php
  JSP
  ASP
  asp.net
  JAVA
  c/c++/c#
  perl
  JavaScript
  Basic
  Delphi
资料搜索
热门文章
·由HTTP 500 Internal server e
·会员系统“找回密码”的制作方
·ASP实现数字和字母组合并生成图
·简单的asp验证码程序示例
·用ASP制作强大的搜索引擎
·如何让图片自动缩放以适合界面
·如何用foreach遍历页面上所有的
·如何实现站点的RSS输出
·无组件实现文件上传/下载
·ASP如何获取真实IP地址
·asp中如何使用 HTML 表格
·采用XMLHTTP编写一个天气预报的
·80004005错误及其解决方法
·asp中如何调试 ASP 脚本
·asp+ajax打造无刷新新闻评论系
最新文章
·ASP教程:8、ASP内建对象Respo
·ASP教程:7、ASP内建对象Reque
·ASP教程:6、ASP脚本循环语句
·ASP教程:5、ASP脚本变量、函数
·ASP教程:4、ASP脚本基础
·ASP教程:3、ASP基础
·ASP教程:2、ASP简介
·ASP教程:1、Are you ready?
·ASP中使用SQL语句教程
·ASP进度条
·由HTTP 500 Internal server e
·Asp无组件生成缩略图
·ASP 系列函数大全(4)
·ASP 系列函数大全(3)
·ASP 系列函数大全(2)
Google
 
实例讲解ASP实现抓取网上房产信息(1)
[ 作者:  加入时间:2007-11-21 14:19:00  来自:Linux联盟收集整理 ]
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> aQrLinux联盟
  <!-- #include file="conn.asp" --> aQrLinux联盟
   aQrLinux联盟
  <!-- #include file="inc/function.asp" --> aQrLinux联盟
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> aQrLinux联盟
  <html> aQrLinux联盟
  <head> aQrLinux联盟
  <title>Untitled Document</title> aQrLinux联盟
  <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> aQrLinux联盟
  <meta http-equiv="refresh" content="300;URL=steal_house.asp"> aQrLinux联盟
  </head> aQrLinux联盟
   aQrLinux联盟
  <body> aQrLinux联盟
  <% aQrLinux联盟
  on error resume next aQrLinux联盟
  ' aQrLinux联盟
  Server.ScriptTimeout = 999999 aQrLinux联盟
  '================================ aQrLinux联盟
  '字符编码函数 aQrLinux联盟
  '======================================== aQrLinux联盟
  Function BytesToBstr(body,code) aQrLinux联盟
   dim objstream aQrLinux联盟
   set objstream = Server.CreateObject("adodb.stream") aQrLinux联盟
   objstream.Type = 1 aQrLinux联盟
   objstream.Mode =3 aQrLinux联盟
   objstream.Open aQrLinux联盟
   objstream.Write body aQrLinux联盟
   objstream.Position = 0 aQrLinux联盟
   objstream.Type = 2 aQrLinux联盟
   objstream.Charset =code aQrLinux联盟
   BytesToBstr = objstream.ReadText aQrLinux联盟
   objstream.Close aQrLinux联盟
   set objstream = nothing aQrLinux联盟
  End Function aQrLinux联盟
   aQrLinux联盟
  '取行字符串在另一字符串中的出现位置 aQrLinux联盟
  Function Newstring(wstr,strng) aQrLinux联盟
   Newstring=Instr(lcase(wstr),lcase(strng)) aQrLinux联盟
   if Newstring<=0 then Newstring=Len(wstr) aQrLinux联盟
  End Function aQrLinux联盟
  '替换字符串函数 aQrLinux联盟
  function ReplaceStr(ori,str1,str2) aQrLinux联盟
  ReplaceStr=replace(ori,str1,str2) aQrLinux联盟
  end function aQrLinux联盟
  '==================================aQrLinux联盟
  function ReadXml(url,code,start,ends) aQrLinux联盟
  set oSend=createobject("Microsoft.XMLHTTP") aQrLinux联盟
  SourceCode = oSend.open ("GET",url,false) aQrLinux联盟
  oSend.send() aQrLinux联盟
  ReadXml=BytesToBstr(oSend.responseBody,code ) aQrLinux联盟
  start=Instr(ReadXml,start) aQrLinux联盟
  ReadXml=mid(ReadXml,start) aQrLinux联盟
  ends=Instr(ReadXml,ends) aQrLinux联盟
  ReadXml=left(ReadXml,ends-1) aQrLinux联盟
  end function aQrLinux联盟
   aQrLinux联盟
  function SubStr(body,start,ends) aQrLinux联盟
  start=Instr(body,start) aQrLinux联盟
  SubStr=mid(body,start+len(start)+1) aQrLinux联盟
  ends=Instr(SubStr,ends) aQrLinux联盟
  SubStr=left(SubStr,ends-1) aQrLinux联盟
  end function aQrLinux联盟
   aQrLinux联盟
  dim getcont,NewsContent aQrLinux联盟
  dim url,title aQrLinux联盟
  url="http://www.***.com"'新闻网址knowsky.com aQrLinux联盟
  getcont=ReadXml(url,"gb2312","<table class=k2 border=""0""","</table>") aQrLinux联盟
  getcont=RegexHtml(getcont) aQrLinux联盟
  dim KeyId,NewsClass,City,Position,HouseType,Level,Area,Price,Demostra aQrLinux联盟
   aQrLinux联盟
  dim ContactMan,Contact aQrLinux联盟
  for i=2 to ubound(getcont) aQrLinux联盟
   response.Write(getcont(i)&"__<br>") aQrLinux联盟
   aQrLinux联盟
   tempLink=mid(getcont(i),instr(getcont(i),"href=""")+6,instr(getcont(i),""" onClick")-10) aQrLinux联盟
   tempLink=replace(tempLink,"../","") aQrLinux联盟
   aQrLinux联盟
   response.Write(i&":"&tempLink&"<br>") aQrLinux联盟
   NewsContent=ReadXml(tempLink,"gb2312","<td valign=""bottom"" width=""400"">","<hr width=""760"" noshade size=""1"" color=""#808080""> ") aQrLinux联盟
   NewsContent=RemoveHtml(NewsContent) aQrLinux联盟
   NewsContent=replace(NewsContent,VbCrLf,"") aQrLinux联盟
   NewsContent=replace(NewsContent,vbNewLine,"") aQrLinux联盟
   NewsContent=replace(NewsContent," ","") aQrLinux联盟
   NewsContent=replace(NewsContent," ","") aQrLinux联盟
   NewsContent=replace(NewsContent," ","") aQrLinux联盟
   NewsContent=replace(NewsContent,"\n","") aQrLinux联盟
   NewsContent=replace(NewsContent,chr(10),"") aQrLinux联盟
   NewsContent=replace(NewsContent,chr(13),"") aQrLinux联盟
   '===============get Content======================= aQrLinux联盟
   response.Write(NewsContent) aQrLinux联盟
   KeyId=SubStr(NewsContent,"列号:","信息类别:") aQrLinux联盟
   NewsClass=SubStr(NewsContent,"类别:","所在城市:") aQrLinux联盟
   City=SubStr(NewsContent,"城市:","房屋具体位置:") aQrLinux联盟
   Position=SubStr(NewsContent,"位置:","房屋类型:") aQrLinux联盟
   HouseType=SubStr(NewsContent,"类型:","楼层:") aQrLinux联盟
   Level=SubStr(NewsContent,"楼层:","使用面积:") aQrLinux联盟
   Area=SubStr(NewsContent,"面积:","房价:") aQrLinux联盟
   Price=SubStr(NewsContent,"房价:","其他说明:") aQrLinux联盟
   Demostra=SubStr(NewsContent,"说明:","联系人:") aQrLinux联盟
   ContactMan=SubStr(NewsContent,"联系人:","联系方式:") aQrLinux联盟
   Contact=SubStr(NewsContent,"联系方式:","信息来源:") aQrLinux联盟
   response.Write("总序列号:"&KeyId&"<br>") aQrLinux联盟
   response.Write("信息类别:"&NewsClass&"<br>") aQrLinux联盟
   response.Write("所在城市:"&City&"<br>") aQrLinux联盟
   response.Write("房屋具体位置:"&Position&"<br>") aQrLinux联盟
   response.Write("房屋类型:"&HouseType&"<br>") aQrLinux联盟
   response.Write("楼层:"&Level&"<br>") aQrLinux联盟
   response.Write("使用面积:"&Area&"<br>") aQrLinux联盟
   response.Write("房价:"&Price&"<br>") aQrLinux联盟
   response.Write("其他说明:"&Demostra&"<br>") aQrLinux联盟
   response.Write("联系人:"&ContactMan&"<br>") aQrLinux联盟
   response.Write("联系方式:"&Contact&"<br>") aQrLinux联盟
   'title=RemoveHTML(aa(i)) aQrLinux联盟
   'response.Write("title:"&title) aQrLinux联盟
   for n=0 to application.Contents.count aQrLinux联盟
   if(application.Contents(n)=KeyId) then aQrLinux联盟
   ifexit=true aQrLinux联盟
   end if aQrLinux联盟
   next aQrLinux联盟
   if not ifexit then aQrLinux联盟
   application(time&i)=KeyId aQrLinux联盟
   '添加到数据库 aQrLinux联盟
   '=============================== aQrLinux联盟
   set rs=server.CreateObject("adodb.recordset") aQrLinux联盟
   rs.open "select top 1 * from news order by id desc",conn,3,3 aQrLinux联盟
   rs.addnew aQrLinux联盟
   rs("NewsClass")=NewsClass aQrLinux联盟
   rs("City")=City aQrLinux联盟
   rs("Position")=Position aQrLinux联盟
   rs("HouseType")=HouseType aQrLinux联盟
   rs("Level")=Level aQrLinux联盟
   rs("Area")=Area aQrLinux联盟
   rs("Price")=Price aQrLinux联盟
   rs("Demostra")=Demostra aQrLinux联盟
   rs("ContactMan")=ContactMan aQrLinux联盟
   rs("Contact")=Contact aQrLinux联盟
   rs.update aQrLinux联盟
   rs.close aQrLinux联盟
   set rs=nothing aQrLinux联盟
   end if aQrLinux联盟
   '=========================================
Linux联盟收集整理 ,转贴请标明原始链接,如有任何疑问欢迎来本站Linux论坛讨论
评论】【加入收藏夹】【 】【打印】【关闭
※ 相关链接
 ·实例讲解ASP实现抓取网上房产信息(2)  (2007-11-21 14:16:51)
 ·纯ASP代码之公历转农历实现(含属相)一则  (2007-11-20 17:12:49)
 ·几个比较好用的asp检查函数推荐  (2007-11-20 17:12:09)
 ·纯ASP代码之公历转农历实现(含属相)  (2007-11-20 17:11:25)
 ·小试修改ASP.NET Forums  (2007-11-20 17:07:49)
 ·基于ASP的收发文管理系统的设计与实现  (2007-11-20 17:01:39)
 ·用ASPJPEG组件制作图片的缩略图和加水印  (2007-11-20 16:59:50)
 ·解密ASP源代码  (2007-11-20 16:57:45)
 ·用Asp备份与恢复SQL Server 数据库  (2007-11-20 16:57:04)
 ·用asp实现的代码批量修改程序  (2007-11-20 16:56:35)