当前位置: 网学 > 编程文档 > ASP > 正文

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

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 13/06/17

鉴于大家对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>
<title>Untitled 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

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

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," ","")
NewsContent=replace(NewsContent,"\n","")
NewsContent=replace(NewsContent,chr(10),"")
NewsContent=replace(NewsContent,chr(13),"")
''===============get Content=======================
response.Write(NewsContent)
KeyId=SubStr(NewsContent,"列号:","信息类别:")
NewsClass=SubStr(NewsConte
  • 下一篇资讯: XMLHTTP批量抓取远程资料
  • 网学推荐

    免费论文

    原创论文

    浏览:
    设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
    版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
    Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
    湘ICP备09003080号