实例讲解asp抓取网上房产的信息

getnews.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"'新闻网址
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(NewsContent,"类别:","所在城市:")
 City=SubStr(NewsContent,"城市:","房屋具体位置:")
 Position=SubStr(NewsContent,"位置:","房屋类型:")
 HouseType=SubStr(NewsContent,"类型:","楼层:")
 Level=SubStr(NewsContent,"楼层:","使用面积:")
 Area=SubStr(NewsContent,"面积:","房价:")
 Price=SubStr(NewsContent,"房价:","其他说明:")
 Demostra=SubStr(NewsContent,"说明:","联系人:")
 ContactMan=SubStr(NewsContent,"联系人:","联系方式:")
 Contact=SubStr(NewsContent,"联系方式:","信息来源:") 
 response.Write("总序列号:"&KeyId&"<br>")
 response.Write("信息类别:"&NewsClass&"<br>")
 response.Write("所在城市:"&City&"<br>")
 response.Write("房屋具体位置:"&Position&"<br>")
 response.Write("房屋类型:"&HouseType&"<br&gt

时间: 2024-10-01 23:15:22

实例讲解asp抓取网上房产的信息的相关文章

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

附:抓取信息的详细页面事例   <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%><!-- #include file="conn.asp" --><!-- #include file="inc/function.asp" --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//E

实例讲解实现抓取网上房产信息的ASP程序_小偷/采集

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%><!-- #include file="conn.asp" --> <!-- #include file="inc/function.asp" --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "h

ASP程序抓取网上房产信息的实例讲解

程序 附:抓取信息的详细页面事例 <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%><!-- #include file="conn.asp" --><!-- #include file="inc/function.asp" --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//

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

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> <!-- #include file="conn.asp" --> <!-- #include file="inc/function.asp" --> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "

实例讲解ASP实现抓取网上房产信息_小偷/采集

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> <!-- #include file="conn.ASP" -->  <!-- #include file="inc/function.asp" --> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" &quo

asp采集抓取网上房产信息的代码_小偷/采集

复制代码 代码如下: <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> <!-- #include file="conn.asp" --> <!-- #include file="inc/function.asp" --> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN&

用Python程序抓取网页的HTML信息的一个小实例

  这篇文章主要介绍了用Python程序抓取网页的HTML信息的一个小实例,用到的方法同时也是用Python编写爬虫的基础,需要的朋友可以参考下 抓取网页数据的思路有好多种,一般有:直接代码请求http.模拟浏览器请求数据(通常需要登录验证).控制浏览器实现数据抓取等.这篇不考虑复杂情况,放一个读取简单网页数据的小例子: 目标数据 将ittf网站上这个页面上所有这些选手的超链接保存下来. 数据请求 真的很喜欢符合人类思维的库,比如requests,如果是要直接拿网页文本,一句话搞定: ? 1 d

asp抓取bing收录与反连代码

asp抓取bing收录与反连代码 <% response.expires = -1 response.addheader "cache-control","no-cache" Response.AddHeader "Pragma","no-cache" wd=Request("d") If Request("s")="bings" Then bingUrl=&q

asp 抓取baidu收录网页数代码

asp 抓取baidu收录网页数代码 <% response.expires = -1 response.addheader "cache-control","no-cache" Response.AddHeader "Pragma","no-cache" wd=Request("d") If Request("s")="baidus" Then BaiduUr