直播中
組件: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") '創(chuàng)建對(duì)象
'接受頁(yè)面參數(shù)
m_strKeyword = server.URLEncode ( trim( Request.QueryString ("keyword")))
'向yahoo發(fā)送搜索關(guān)鍵字"c++"的請(qǐng)求
m_objMyHttp.Url = "http://search.yahoo.com/bin/search?p="&m_strKeyword&""
'發(fā)送請(qǐng)求
m_objMyHttp.SendRequest ()
'把html取到局部變量中
m_strHtml = m_objMyHttp.Html
set m_objMyHttp = nothing
'分析,利用標(biāo)志位
dim m_strBeginTag , m_strEndTag , m_strUrl
'設(shè)置標(biāo)志位
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
%>