主题:  [讨论] 关于 XMLHTTP

{ 在指尖上绽放的花朵 }

职务:普通成员
等级:5
金币:14.0
发贴:3209
注册:2002/7/25 21:24:11
#12005/1/27 18:39:13
今天在网上乱转。。。。

发现了 啥都有兄 的一个教程。。。

可惜因为年代久远。。文件已经不能下载了。。。

另外。。。不知道现在 XMLHTTP 还能这样用吗?

相关URL:http://www.5d.cn/bbs/archivecontent.asp?id=1168750



缺缺

职务:管理员
等级:8
金币:41.0
发贴:9620
注册:2004/1/14 19:14:47
#22005/1/27 19:00:26
可以.
asp.net2.0可以实现无刷新请求服务器,其底层就是XMLHTTP

找了一下,我好像也没有源程序了.



缺缺

职务:管理员
等级:8
金币:41.0
发贴:9620
注册:2004/1/14 19:14:47
#32005/1/27 19:10:59
上次写的金牌榜的源代码:


//Powered By Allinhands.QQ:1707477.E-mail:Allinhands@21cn.com
<%
'乾坤大挪移
function getPage(url)
    dim Http
    set Http=server.createobject("MSXML2.XMLHTTP")
    Http.open "GET",url,false
    Http.setrequestHeader "Accept-Language","zh-cn"
Http.setRequestHeader "content-type","application/x-www-form-urlencoded"
    Http.send()
    if Http.readystate<>4 then 
        exit function
    end if
    getPage=Bytes2bStr(Http.responseBody)
    set http=nothing
    if err.number<>0 then err.Clear 
end function

Function Bytes2bStr(vin)
 Dim BytesStream,StringReturn
 Set BytesStream = Server.CreateObject("ADODB.Stream")
 With BytesStream
  .Open                   
  .WriteText vin
  .Position = 0    
  .Charset = "GB2312" 
  .Position = 2 
  StringReturn = .ReadText
  .close 
 End With
 Set BytesStream = Nothing 
 Bytes2bStr = StringReturn
End Function

Function GetStr(HTML,shtml,ehtml)
	dim StartPos,EndPos,Length
	if instr(1,HTML,shtml) then
		StartPos=Instr(1,HTML,shtml)+len(shtml)
	else
		StartPos=1
	end if
	if instr(StartPos,HTML,ehtml) then
		EndPos=Instr(StartPos,HTML,ehtml)
	else
		EndPos=len(HTML)+1
	end if
	Length=EndPos-StartPos
	GetStr=Mid(HTML,StartPos,Length)
End Function


function RegExpTest(patrn, strng)
	Dim regEx,Match,Matches,RetStr   
	Set regEx = New RegExp      
	regEx.Pattern= patrn         
	regEx.IgnoreCase = True     
	regEx.Global=True                    
	set Matches=regEx.Execute(strng)   
	for each Match in Matches     
			RetStr=RetStr&Match.SubMatches(0)&","
	Next
	RegExpTest=RetStr
end function

%>
<%
vColor=Request.QueryString("color")
vSize=Request.QueryString("size")
vMode=Request.QueryString("mode")
Response.Write("<!--"&vColor&"-->")
if vColor="" then
	vColor="#FF9900"
end if

if vSize="" then
	vSize="12"
end if

if vMode="" then
	vMode="n"
end if


HTML=getPage("http://2004.163.com/special/j/jpb.html")
HTML=GetStr(HTML,">总</td>","<!!piecename=""中国夺牌历程回顾"">")
Table=Split(HTML,"</table>")(0)
Country=Split(Table,"</tr>")

for i = 0 to UBound(Country)
	if Instr(Country(i),"中国")>0 then
		C_China=Country(i)
		Order=i
		exit for
	end if
next

Num=SPlit(REgExpTest(">(\d+)<",C_China),",")
Gold=Num(1)
Silver=Num(2)
Copper=Num(3)
%>
var outstr="";
<%
Response.write("var Gold="&Gold&";"&vbcrlf)
Response.write("var Silver="&Silver&";"&vbcrlf)
Response.write("var Copper="&Copper&";"&vbcrlf)
Response.write("var Order="&Order&";"&vbcrlf)

if vMode="n" then
%>
outstr+="<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"600\" align=\"center\">";
outstr+="  <tr>";
outstr+="   <td colspan=\"8\"><img src=\"http://www.mofao.com/images/2004_r1_c1.jpg\" width=\"600\" height=\"59\" ></td>";
outstr+="  </tr>";
outstr+="  <tr>";
outstr+="   <td><img  src=\"http://www.mofao.com/images/2004_r2_c1.jpg\" width=\"259\" height=\"41\" ></td>";
outstr+="    <td width=\"29\" background=\"http://www.mofao.com/images/2004_r2_c2.jpg\" style=\"color:<%= vColor %>;font:bold <%= vSize %>pt Verdana;\">"+Order+"</td>";
outstr+="   <td><img src=\"http://www.mofao.com/images/2004_r2_c3.jpg\" width=\"65\" height=\"41\" ></td>";
outstr+="    <td width=\"33\" background=\"http://www.mofao.com/images/2004_r2_c4.jpg\" style=\"color:<%= vColor %>;font:bold <%= vSize %>pt Verdana;\">"+Gold+"</td>";
outstr+="   <td><img src=\"http://www.mofao.com/images/2004_r2_c5.jpg\" width=\"70\" height=\"41\" ></td>";
outstr+="    <td width=\"35\" background=\"http://www.mofao.com/images/2004_r2_c6.jpg\" style=\"color:<%= vColor %>;font:bold <%= vSize %>pt Verdana;\">"+Silver+"</td>";
outstr+="   <td><img src=\"http://www.mofao.com/images/2004_r2_c7.jpg\" width=\"65\" height=\"41\" ></td>";
outstr+="    <td width=\"44\" background=\"http://www.mofao.com/images/2004_r2_c8.jpg\" style=\"color:<%= vColor %>;font:bold <%= vSize %>pt Verdana;\">"+Copper+"</td>";
outstr+="  </tr>";
outstr+="</table>";
<%
elseif vMode="s" then
%>
outstr+="<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"211\">";
outstr+="  <tr>";
outstr+="   <td rowspan=\"4\"><img src=\"http://www.mofao.com/images/2004_s_r1_c1.jpg\" width=\"114\" height=\"100\" ></td>";
outstr+="   <td><img src=\"http://www.mofao.com/images/2004_s_r1_c2.jpg\" width=\"59\" height=\"28\" ></td>";
outstr+="    <td width=\"38\" background=\"http://www.mofao.com/images/2004_s_r1_c3.jpg\" style=\"color:<%= vColor %>;font:bold <%= vSize %>pt Verdana;\">"+Order+"</td>";
outstr+="  </tr>";
outstr+="  <tr>";
outstr+="   <td><img src=\"http://www.mofao.com/images/2004_s_r2_c2.jpg\" width=\"59\" height=\"22\" ></td>";
outstr+="    <td background=\"http://www.mofao.com/images/2004_s_r2_c3.jpg\" style=\"color:<%= vColor %>;font:bold <%= vSize %>pt Verdana;\">"+Gold+"</td>";
outstr+="  </tr>";
outstr+="  <tr>";
outstr+="   <td><img src=\"http://www.mofao.com/images/2004_s_r3_c2.jpg\" width=\"59\" height=\"22\" ></td>";
outstr+="    <td background=\"http://www.mofao.com/images/2004_s_r3_c3.jpg\" style=\"color:<%= vColor %>;font:bold <%= vSize %>pt Verdana;\">"+Silver+"</td>";
outstr+="  </tr>";
outstr+="  <tr>";
outstr+="   <td><img src=\"http://www.mofao.com/images/2004_s_r4_c2.jpg\" width=\"59\" height=\"28\" ></td>";
outstr+="    <td background=\"http://www.mofao.com/images/2004_s_r4_c3.jpg\" style=\"color:<%= vColor %>;font:bold <%= vSize %>pt Verdana;\">"+Copper+"</td>";
outstr+="  </tr>";
outstr+="</table>";
<%
end if
%>
document.write(outstr)



{ 在指尖上绽放的花朵 }

职务:普通成员
等级:5
金币:14.0
发贴:3209
注册:2002/7/25 21:24:11
#42005/1/27 19:16:50
allinhands在上个帖子中说
引用:
上次写的金牌榜的源代码:



我在小熊在线看到过这个呢。。。。

嘿嘿。。研究中~~~



蓝鲸

职务:版主
等级:5
金币:42.1
发贴:2614
注册:2001/12/20 15:57:57
#52005/1/27 21:46:24
我是典型的实用主义,用时才看书,虽然xmlhttp听了很多,但很不了解,空了我看看。


非常大鱼

浮尘

职务:普通成员
等级:3
金币:7.0
发贴:1258
注册:2001/11/19 12:41:09
#62005/1/28 11:18:15
感觉这种方法的性能不好,如果要从一个很大的面页中提取的话,会很慢的吧。



浮尘

职务:普通成员
等级:3
金币:7.0
发贴:1258
注册:2001/11/19 12:41:09
#72005/1/28 11:20:01
再有,如果原页面改版后,就找不到了。



缺缺

职务:管理员
等级:8
金币:41.0
发贴:9620
注册:2004/1/14 19:14:47
#82005/1/28 12:15:43
一次性使用而已.谁有长期去调用呢?



还有,XMLHTTP并不是只有这个用处.