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

佐助之墓

佐助之墓

2016-01-29 17:49

实例讲解ASP实现抓取网上房产信息,实例讲解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

<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

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

'取行字符串在另一字符串中的出现位置
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

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

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

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,"

展开更多 50%)
分享

猜你喜欢

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

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

安居客怎么发布房产信息

手机软件 应用软件
安居客怎么发布房产信息

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

用post方法从网上抓取信息

Web开发
用post方法从网上抓取信息

简易实现网上动态信息发布

编程语言 网络编程
简易实现网上动态信息发布

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

用ASP实现远程抓取网页到本地数据库

Web开发
用ASP实现远程抓取网页到本地数据库

基于ASP网上书店的设计与实现

Web开发
基于ASP网上书店的设计与实现

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

利用客户端js实现汉字简体繁体转换

利用客户端js实现汉字简体繁体转换

维护系统也能偷懒 让Win XP自己修复故障

维护系统也能偷懒 让Win XP自己修复故障
下拉加载更多内容 ↓