动网论坛,站长建站首选,国内使用量最多的论坛软件 动网论坛官方技术讨论区 站长工具 申请属于您自己的免费论坛
首页 | 新闻资讯 | 网站运营 | 网络编程 | 数据库 | 服务器 | 网页设计 | 图像媒体 | 网络应用 | 搜索优化 | 资源下载 | 动网主机 | DVBOX
    本站内  互联网 ASP论坛  ASP.Net论坛  PHP论坛
   Asp → 阅读文章

 利用自己开发的vc组件结合asp实现网上实时搜索

作者来源: 
阅读 3782 人次 , 2000-9-18 

    最近有人问怎么用asp来得到别的网站的网页,并分析后利用它的数据,纯asp是做不到这点的,所以我用vc做了个http组件,很简陋,不如asphttp,因为时间问题我暂时没有做post方法,只能用get方法,但要应付象yahoo,新浪等大的搜索引擎还是绰绰有余的。利用这个组件向这些站发送请求,然后用asp分析并得到其中有用的数据,分析的思路就是利用标志位,如果想要做到通用,可以使用配置文件。我就不多解释了,看例子吧。我的那个组件及源代码下载地址如下:

组件:http://homepage.qdcatv.com.cn/bigeagle/myhttp.zip
源代码:http://homepage.qdcatv.com.cn/bigeagle/myhttpcode.zip

下面是asp例子程序,搜索引擎用的是yahoo

test2.asp

<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>

<form action="test1.asp" method="get">
<input type=text name="keyword">
<input type=submit value="查找">
</form>

</BODY>
</HTML>


test1.asp
<%
    dim m_objMyHttp , m_strHtml
    set m_objMyHttp = server.CreateObject ("myhttp.OpenUrl")  '创建对象
    
    '接受页面参数
    m_strKeyword = server.URLEncode ( trim( Request.QueryString ("keyword")))
    
     '向yahoo发送搜索关键字"c++"的请求
    m_objMyHttp.Url = "http://search.yahoo.com/bin/search?p="&m_strKeyword&""  
    
    '发送请求
    m_objMyHttp.SendRequest ()
    
    '把html取到局部变量中
    m_strHtml = m_objMyHttp.Html
    set m_objMyHttp = nothing
    
    
    '分析,利用标志位
    dim m_strBeginTag , m_strEndTag , m_strUrl
    
    '设置标志位
    m_strBeginTag = "<table border=0 cellpadding=0 cellspacing=0><tr><td height=5></td></tr></table><dd><li>"
    m_strEndTag   = "</a>"
    
    m_intBegin = 1
    m_intEnd = 0
    do while not m_intBegin = 0
       m_intBegin = instr(m_intBegin + 1 , m_strHtml , m_strBeginTag)
       m_intEnd   = instr(m_intBegin + len(m_strBeginTag) , m_strHtml , m_strEndTag)
       m_strUrl = mid (m_strHtml , m_intBegin+len(m_strBeginTag) , m_intEnd - m_intBegin - len(m_strBeginTag) +4 )
       if m_intBegin <> 0 then
          Response.Write m_strUrl + "<br>"
       end if   
    Loop   
    
%>  
 本文Tags组件  
 收藏本文  打印本文  论坛讨论  关闭窗口
· 上一篇:彻底终结浏览器Cahce页面的解决方案
· 下一篇:一个用vc开发的域名查询组件(源代码及说明)
· Ad Rotator 组件参考(三) - 重定向文件 
· 十天学会ASP之第九天
· JScript 方法 - charAt 方法
· 如何用ASP编写网站统计系统二
· 取得浏览者的离开时间


关于本站 | 联系我们 | 业务合作 | 客户案例 | 诚聘英才 | 广告合作 | 收藏本站
海口动网先锋网络科技有限公司版权所有
Copyright © 2000 - 2006 Cndw.Com
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077