|            
                         最近有人问怎么用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 
  %>  (出处:热点网络)  
 |