实例讲解ASP实现抓取网上房产信息

2016-01-29 17:49 0 1 收藏

实例讲解ASP实现抓取网上房产信息,实例讲解ASP实现抓取网上房产信息

【 tulaoshi.com - ASP 】

 

 <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%
<!-- #include file="conn.asp" --

<!-- #include file="inc/function.asp" --
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"
<html
<head
<titleUntitled Document</title
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"
<meta http-equiv="refresh" content="300;URL=steal_house.asp"
</head

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/asp/)

<body
<%
on error resume next
'
Server.ScriptTimeout = 999999
'========================================================
'字符编码函数
'====================================================
Function BytesToBstr(body,code)
        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 =code
        BytesToBstr = objstream.ReadText 
        objstream.Close
        set objstream = nothing
End Function

'取行字符串在另一字符串中的出现位置
Function Newstring(wstr,strng)
        Newstring=Instr(lcase(wstr),lcase(strng))
        if Newstring<=0 then Newstring=Len(wstr)
End Function
'替换字符串函数
function ReplaceStr(ori,str1,str2)
ReplaceStr=replace(ori,str1,str2)
end function
'====================================================
function ReadXml(url,code,start,ends)
set oSend=createobject("Microsoft.XMLHTTP")
SourceCode = oSend.open ("GET",url,false)
oSend.send()
ReadXml=BytesToBstr(oSend.responseBody,code )
start=Instr(ReadXml,start)
ReadXml=mid(ReadXml,start)
ends=Instr(ReadXml,ends)
ReadXml=left(ReadXml,ends-1)
end function

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/asp/)

function SubStr(body,start,ends)
start=Instr(body,start)
SubStr=mid(body,start+len(start)+1)
ends=Instr(SubStr,ends)
SubStr=left(SubStr,ends-1)
end function

dim getcont,NewsContent
dim url,title
url="http://www.***.com"'新闻网址knowsky.com
getcont=ReadXml(url,"gb2312","<table class=k2 border=""0""","</table")
getcont=RegexHtml(getcont)
dim KeyId,NewsClass,City,Position,HouseType,Level,Area,Price,Demostra

dim ContactMan,Contact
for i=2 to ubound(getcont)
 response.Write(getcont(i)&"__<br")
 
 tempLink=mid(getcont(i),instr(getcont(i),"href=""")+6,instr(getcont(i),""" onClick")-10)
 tempLink=replace(tempLink,"../","")
 
 response.Write(i&":"&tempLink&"<br")
 NewsContent=ReadXml(tempLink,"gb2312","<td valign=""bottom"" width=""400""","<hr width=""760"" noshade size=""1"" color=""#808080"" ")
 NewsContent=RemoveHtml(NewsContent)
 NewsContent=replace(NewsContent,VbCrLf,"")
 NewsContent=replace(NewsContent,vbNewLine,"")
 NewsContent=replace(NewsContent," ","")
 NewsContent=replace(NewsContent," ","")
 NewsContent=replace(NewsContent,"&nbsp;","")
 NewsContent=replace(NewsContent,"n","")
 NewsContent=replace(NewsContent,chr(10),"")
 NewsContent=replace(NewsContent,chr(13),"")
 '===============get Content=======================
 response.Write(NewsContent)
 KeyId=SubStr(NewsContent,"列号:","信息类别:")
 NewsClass=SubStr(NewsContent,"类别:","所在城市:")
 City=SubStr(NewsContent,"

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

延伸阅读
标签: Delphi
  在网络管理中,有时需要通过监视远程计算机屏幕来了解网上微机的使用情况。虽然,市面上有很多软件可以实现该功能,有些甚至可以进行远程控制,但在使用上缺乏灵活性,如无法指定远程计算机屏幕区域的大小和位置,进而无法在一屏上同时监视多个屏幕。其实,可以用Delphi自行编制一个灵活的远程屏幕抓取工具,简述如下。 一...
标签: ASP
摘要:在基于/的应用环境中,上传各种类型的文件一直是困扰用户文件管理应用的难题之一。在HTTP中上传文件有三种机制:RFC1867,PUT和WebDAV。常用的实现方法是利用在RFC1867中引入的一个新类型:File以及ADO Stream对象。本文对上述上传方法及实现原理作了论述,并给出了具体解决实例。 ASP FILE对象 当前,基于/模式的应用比较流...
通过程序自动的读取其它网站网页显示的信息,类似于爬虫程序。比方说我们有一个系统,要提取BaiDu网站上歌曲搜索排名。分析系统在根据得到的数据进行数据分析。为业务提供参考数据。 为了完成以上的需求,我们就需要模拟浏览器浏览网页,得到页面的数据在进行分析,最后把分析的结构,即整理好的数据写入数据库。那么我们的思路就是: ...
* 豆腐制作 都是精品 http://www.asp888.net 豆腐技术站 如果您转贴 本文 请 保留版权信息 */ 豆腐在以前的文章中 讲过 如何用 PHp 和 Asp 跨站抓取别的站点的页面,今天我们来测试一下 asp+ 是怎么实现 跨站抓取 别的站点的页面 Code Listing <%@ Assembly Name="System.Net" % <%@ Import Namespace="System.Net" % <%@ Import Nam...
标签: Web开发
本管理程序的主要功能有:1、图书列表展示功能;2、图书放置购物车、移去购物车和清空购物车功能;3、购书结帐功能;4、新会员注册功能。 Iindex.asp 首页。框架结构。上框架连接Top.htm页面,下框架连接Booklist页面。 htmlheadmeta http-equiv="Content-Type" content="text/html; charset=gb2312"title网上图...

经验教程

943

收藏

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