asp采集代码示例

下面是一侧ASP采集页面内容最基础的必备源代码,修改以下的代码需要有一定的ASP基础。

以下是引用片段:
< % 
 ’功能:asp采集代码 
’作者:wangsdong 
’备注:支持原创程序,请保留此信息,谢谢 
url="http://sports.sina.com.cn/k/2008-09-15/04593948756.shtml" 
str=getHTTPPage(url) 
title=strcut(str,"<h1 id=""artibodyTitle"" style=""color:#03005C;"">","</h1>",2) 
content=strcut(str,"<!-- 正文内容 begin -->","<!-- 正文内容 end -->",2) 
response.write "新闻标题<br><b>"&title&"</b><br><br><br>新闻内容:<br>"&content 
Function getHTTPPage(url) 
On Error Resume Next 
dim http 
set http=Server.createobject("Microsoft.XMLHTTP") 
Http.open "GET",url,false 
Http.send() 
if Http.readystate<>4 then 
exit function 
end if 
getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312") 
set http=nothing 
If Err.number<>0 then 
Response.Write "<p align=’center’><font color=’red’><b>服务器获取文件内容出错</b></font></p>" 
Err.Clear 
End If 
End Function 
Function BytesToBstr(body,Cset) 
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 = Cset 
BytesToBstr = objstream.ReadText 
objstream.Close 
set objstream = nothing 
End Function 
’截取字符串,1.包括起始和终止字符,2.不包括 
Function strCut(strContent,StartStr,EndStr,CutType) 
Dim strHtml,S1,S2 
strHtml = strContent 
On Error Resume Next 
Select Case CutType 
Case 1 
S1 = InStr(strHtml,StartStr) 
S2 = InStr(S1,strHtml,EndStr)+Len(EndStr) 
Case 2 
S1 = InStr(strHtml,StartStr)+Len(StartStr) 
S2 = InStr(S1,strHtml,EndStr) 
End Select 
If Err Then 
strCute = "<p align=’center’>没有找到需要的内容。</p>" 
Err.Clear 
Exit Function 
Else 
strCut = Mid(strHtml,S1,S2-S1) 
End If 
End Function 
% > 
时间: 2024-09-12 14:38:20

asp采集代码示例的相关文章

简单的asp采集代码教程_小偷/采集

采集开始 第一步是分析要采集的页面. 使用浏览器打开要采集的页面(如:http://sports.sina.com.cn/k/2008-09-15/04593948756.shtml,你可以其他页面),打开后,点击右键,查源文件. 第二步,找到要采集的内容所在位置. 假如我要采集这个页面上的标题和内容所在的位置: 标题在<h1 id="artibodyTitle" style="color:#03005C;">和</h1>之间 内容在<

asp采集-ASP采集小偷,指定数据无法抓取

问题描述 ASP采集小偷,指定数据无法抓取 http://chaxun.ttk.cn:8084/BarScanRecord/trackInfo_jsp.jsp?expBill=560230596486&opeCate=2 页面里我只想偷取,当前状态:已签收,但一直无法实现,请指教以下为小偷代码 <% '功能:asp采集代码 'url=""http://www.kuaidi100.com/query?type=tiantian&postid=560230596486

ASP.NET的地址重写(URLRewriter)实现原理及代码示例

一.概述 访问者输入:http://wu-jian.cnbolgs.com/default.aspx,实际请求和响应的地址却是:http://www.cnblogs.com/wu-jian/default.aspx, 这就是UrlRewrite,除了实现二级域名功能,它在简化用户输入地址.SEO.网站版本迭代更新等多个方面发挥着重要作用. 微软曾在.net framework 1.1中提供过一个名为URLRewriter的小工具供开发人员轻松实现UrlRewrite,下载地址为:http://d

asp 文件采集代码

asp 文件采集代码 我们用到xmlhttp来抓取远程服务器文件的内容再把它转换成相关编码 <% Function getHTTPPage(Path)         t = GetBody(Path)         getHTTPPage=BytesToBstr(t,"UTF-8") End function Function GetBody(url)         on error resume next         Set Retrieval = CreateObj

ASP.NET的地址重写“.NET研究”(URLRewriter)实现原理及代码示例

一.概述 访问者输入:http://wu-jian.cnbolgs.com/default.aspx,实际请求和响应的地址却是:http://www.cnblogs.com/wu-jian/default.aspx, 这就是UrlRewrite,除了实现二级域名功能,它在简化用户输入地址.SEO.网站版本迭代更新等多个方面发挥着重要作用. 微软曾在.net framework 1.1中提供过一个名为URLRewriter的小工具供开发人员轻松实现UrlRewrite,下载地址为:http://d

最新版 INSPINIA IN+ - WebApp Admin Theme v2.7.1,包含asp.net MVC5示例代码,做管理系统最佳的选择。

下载地址:http://download.csdn.net/download/wulang1988/10039402 最新版 INSPINIA IN+ - WebApp Admin Theme v2.7.1 (57.8 MB)包含asp.net MVC5示例代码,做管理系统最佳的选择. 官方$36刀:https://wrapbootstrap.com/theme/inspinia-responsive-admin-theme-WB0R5L90S        

一起谈.NET技术,ASP.NET的地址重写(URLRewriter)实现原理及代码示例

一.概述 访问者输入:http://wu-jian.cnbolgs.com/default.aspx,实际请求和响应的地址却是:http://www.cnblogs.com/wu-jian/default.aspx, 这就是UrlRewrite,除了实现二级域名功能,它在简化用户输入地址.SEO.网站版本迭代更新等多个方面发挥着重要作用. 微软曾在.net framework 1.1中提供过一个名为URLRewriter的小工具供开发人员轻松实现UrlRewrite,下载地址为:http://d

Visual Basic .NET 代码示例:与 Windows 服务交互 (2003年2月17日)

Visual Basic .NET 代码示例:与 Windows 服务交互 (2003年2月17日) 此示例显示了如何通过代码控制已安装的 Windows 服务. http://www.microsoft.com/china/msdn/library/dnvssamp/html/vbcs_InteractingwithaWindowsService.asp

asp.net发送邮件示例分享

 这篇文章主要介绍了asp.net发送邮件示例分享,需要的朋友可以参考下 mailhelper  -------mail帮助类    代码如下: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mail;   /// <summary> ///mailhelper 的摘要说明 /// </summary> public clas