﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>IT博客-登陆不起啦(aiut) Thingking in B/S-随笔分类-服务器端脚本</title><link>http://www.cnitblog.com/aiut/category/1003.html</link><description /><language>zh-cn</language><lastBuildDate>Wed, 05 Oct 2011 00:41:36 GMT</lastBuildDate><pubDate>Wed, 05 Oct 2011 00:41:36 GMT</pubDate><ttl>60</ttl><item><title>关于Adodb.Stream 的使用说明</title><link>http://www.cnitblog.com/aiut/archive/2005/11/17/4643.html</link><dc:creator>登陆不起啦</dc:creator><author>登陆不起啦</author><pubDate>Thu, 17 Nov 2005 14:12:00 GMT</pubDate><guid>http://www.cnitblog.com/aiut/archive/2005/11/17/4643.html</guid><wfw:comment>http://www.cnitblog.com/aiut/comments/4643.html</wfw:comment><comments>http://www.cnitblog.com/aiut/archive/2005/11/17/4643.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/aiut/comments/commentRss/4643.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/aiut/services/trackbacks/4643.html</trackback:ping><description><![CDATA[<TABLE class=showinfo style="TABLE-LAYOUT: fixed; WORD-BREAK: break-all" cellSpacing=0 cellPadding=3 width="100%" align=center border=0>
<TBODY>
<TR>
<TD class=showTitle align=middle>关于Adodb.Stream 的使用说明</TD></TR>
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding=0 align=left border=0>
<TBODY>
<TR>
<TD>
<SCRIPT language=javascript src="/ad/js/edu_left_300-300.js"></SCRIPT>
</TD></TR></TBODY></TABLE>组件："Adodb.Stream" <BR><BR>有下列方法： <BR><BR><FONT color=#ff0000>Cancel 方法</FONT> <BR>使用方法如下 <BR>Object.Cancel <BR>说明：取消执行挂起的异步 Execute 或 Open 方法的调用。 <BR><BR><FONT color=#ff0000>Close 方法</FONT> <BR>使用方法如下 <BR>Object.Close <BR>：关闭对像 <BR><BR><FONT style="BACKGROUND-COLOR: #ffffff" color=#ff0000>CopyTo 方法</FONT> <BR>使用方法如下 <BR>Object.CopyTo(destStream,[CharNumber]) <BR>说明：将对像的数据复制，destStream指向要复制的对像，CharNumber为可选参数，指要复制的字节数，不选为全部复制。<BR>&nbsp;<BR><FONT color=#ff0000>Flush 方法</FONT> <BR>使用方法如下 <BR>Object.Flush <BR>说明： <BR><BR><FONT color=#ff0000>LoadFromFile 方法</FONT> <BR>使用方法如下 <BR>Object.LoadFromFile(FileName) <BR>说明:将FileName指定的文件装入对像中,参数FileName为指定的用户名。 <BR><BR><FONT color=#ff0000>Open 方法 <BR></FONT>使用方法如下 <BR>Object.Open(Source,[Mode],[Options],[UserName],[Password]) <BR>说明：打开对像， <BR>参数说明：Sourece 对像源，可不指定 <BR>Mode 指定打开模式，可不指定，可选参数如下： <BR>adModeRead =1 <BR>adModeReadWrite =3 <BR>adModeRecursive =4194304 <BR>adModeShareDenyNone =16 <BR>adModeShareDenyRead =4 <BR>adModeShareDenyWrite =8 <BR>adModeShareExclusive =12 <BR>adModeUnknown =0 <BR>adModeWrite =2 <BR>Options 指定打开的选项，可不指定，可选参数如下： <BR>adOpenStreamAsync =1 <BR>adOpenStreamFromRecord =4 <BR>adOpenStreamUnspecified=-1 <BR>UserName 指定用户名，可不指定。 <BR>Password 指定用户名的密码 <BR><BR><FONT color=#ff0000>Read 方法</FONT> <BR>使用方法如下： <BR>Object.Read(Numbytes) <BR>说明：读取指定长度的二进制内容。 <BR>参数说明：Numbytes指定的要读取的找度，不指定则读取全部。 <BR><BR><FONT color=#ff0000>ReadText 方法</FONT> <BR>使用方法如下： <BR>Object.ReadText(NumChars) <BR>说明：读取指定长度的文本 <BR>参数说明：NumChars指定的要读取的找度，不指定则读取全部。 <BR><BR><FONT color=#ff0000>SaveToFile 方法</FONT> <BR>使用方法如下： <BR>Object.SaveToFile(FileName,[Options]) <BR>说明：将对像的内容写到FileName指定的文件中 <BR>参数说明：FileName指定的文件 <BR>Options 存取的选项，可不指定，可选参数如下： <BR>adSaveCreateNotExist =1 <BR>adSaveCreateOverWrite =2 <BR><BR><FONT color=#ff0000>SetEOS 方法 <BR></FONT>使用方法如下： <BR>Object.setEOS() <BR>说明： <BR><BR><FONT color=#ff0000>SkipLine 方法 <BR></FONT>使用方法如下： <BR>Object.SkipLine() <BR>说明： <BR><BR><FONT color=#ff0000>Write 方法</FONT> <BR>使用方法如下： <BR>Object.Write(Buffer) <BR>说明：将指定的数据装入对像中。 <BR>参数说明：Buffer 为指定的要写入的内容。<BR>&nbsp;<BR><FONT color=#ff0000>WriteText 方法</FONT> <BR>使用方法如下： <BR>Object.Write(Data,[Options]) <BR>说明：将指定的文本数据装入对像中。 <BR>参数说明：Data 为指定的要写入的内容。 <BR>Options 写入的选项，可不指定，可选参数如下： <BR>adWriteChar =0 <BR>adWriteLine =1 <BR><BR><BR><BR><BR>有下列属性： <BR><FONT color=#ff0000>Charset</FONT> <BR>EOS 返回对像内数据是否为空。 <BR><BR><FONT color=#ff0000>LineSeparator</FONT> 指定换行格式，可选参数有 <BR>adCR =13 <BR>adCRLF =-1 <BR>adLF =10 <BR><BR><FONT color=#ff0000>Mode</FONT> 指定或返加模式。 <BR><BR><FONT color=#ff0000>Position</FONT> 指定或返加对像内数据的当前指针。 <BR><BR><FONT color=#ff0000>Size</FONT> 返回对像内数据的大小。 <BR><BR><FONT color=#ff0000>State</FONT> 返加对像状态是否打开。 <BR><BR><FONT color=#ff0000>Type</FONT> 指定或返回的数据类型，可选参数为： <BR>adTypeBinary =1 <BR>adTypeText =2 <BR><BR><IMG height=20 src="http://www.cnitblog.com/Emoticons/QQ/laf.gif" width=20 border=0><IMG height=20 src="http://www.cnitblog.com/Emoticons/QQ/laf.gif" width=20 border=0><IMG height=20 src="http://www.cnitblog.com/Emoticons/QQ/laf.gif" width=20 border=0><IMG height=20 src="http://www.cnitblog.com/Emoticons/QQ/laf.gif" width=20 border=0><IMG height=20 src="http://www.cnitblog.com/Emoticons/QQ/laf.gif" width=20 border=0></TD></TR></TBODY></TABLE><img src ="http://www.cnitblog.com/aiut/aggbug/4643.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/aiut/" target="_blank">登陆不起啦</a> 2005-11-17 22:12 <a href="http://www.cnitblog.com/aiut/archive/2005/11/17/4643.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转]小偷是怎样炼成的(asp,小偷,xmlhttp,正则,joyo.com) 作者：blue1019</title><link>http://www.cnitblog.com/aiut/archive/2005/11/17/4642.html</link><dc:creator>登陆不起啦</dc:creator><author>登陆不起啦</author><pubDate>Thu, 17 Nov 2005 13:57:00 GMT</pubDate><guid>http://www.cnitblog.com/aiut/archive/2005/11/17/4642.html</guid><wfw:comment>http://www.cnitblog.com/aiut/comments/4642.html</wfw:comment><comments>http://www.cnitblog.com/aiut/archive/2005/11/17/4642.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/aiut/comments/commentRss/4642.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/aiut/services/trackbacks/4642.html</trackback:ping><description><![CDATA[<TABLE class="fixedTable blogpost" cellSpacing=0 width="100%" border=0>
<TBODY>
<TR>
<TD class=ellipse><SPAN class=bvTitle id=subjcns!1pvHzJ2FFuxbZKKCb2_fpGcA!243><STRONG>小偷是怎样炼成的(asp,小偷,xmlhttp,正则,joyo.com)<BR>作者：blue1019<BR>来源：<A href="http://spaces.msn.com/members/blue1019/Blog/cns!1pvHzJ2FFuxbZKKCb2_fpGcA!305.entry">http://spaces.msn.com/members/blue1019/Blog/cns!1pvHzJ2FFuxbZKKCb2_fpGcA!305.entry</A></STRONG></SPAN></TD></TR>
<TR>
<TD class=bvh8><STRONG></STRONG></TD></TR>
<TR>
<TD id=msgcns!1pvHzJ2FFuxbZKKCb2_fpGcA!243>
<DIV><FONT color=#3366ff><STRONG>关于</STRONG></FONT></DIV>
<DIV><FONT color=#3366ff>”认真编程“分类写的是一些编程经验，无相关知识将无法看懂。</FONT></DIV>
<DIV>&nbsp;&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>这几个月我们的商城建设起来了，“哈尔滨购物网”成了名副其实的购物网。<BR>这时间里相关部门就开始研究其他的购物网，比如当当，卓越。他们想要一份以excel形式存储的包含上述网站的商品信息以便统计、分析。当然卓越、当当没有什么理由把数据都给我们，于是我们想到了“偷”。于是我把周杰伦的七里香放进cd-rom驱动器开始了“盗窃”。</DIV>
<DIV>&nbsp;</DIV>
<DIV>一切从<A href="http://www.baidu.com/"><FONT color=#0d5d91>www.baidu.com</FONT></A>开始，在搜索的文本框里输入“asp 小偷”很多的信息就被检索出来了。我进入了一个叫“ASP小偷(远程数据获取)程序入门教程”的标题:</DIV>
<DIV><A href="http://www.pconline.com.cn/pcedu/empolder/wz/asp/0505/628553.html"><FONT color=#0d5d91>http://www.pconline.com.cn/pcedu/empolder/wz/asp/0505/628553.html</FONT></A></DIV>
<DIV><FONT color=#0d5d91></FONT>&nbsp;</DIV>
<DIV>总结了文章的内容得出结论，“偷”其实就是通过微软的XMLHTTP这个COM组件进行的。还好XMLHTTP这个词并不陌生。</DIV>
<DIV><BR>我又在baidu上检索到“xmlHTTP技术资料"这条信息。</DIV>
<DIV><A href="http://www.youren.com/Article/programme/xml/200505/4768.html"><FONT color=#0d5d91>http://www.youren.com/Article/programme/xml/200505/4768.html</FONT></A></DIV>
<DIV><FONT color=#0d5d91></FONT>&nbsp;</DIV>
<DIV>XMLHTTP能干很多事情，但是在这里我们要它干的只是：将指定的网页的HTML代码读出。<BR>如果通过程序读出对方（当当、卓越）的相应HTML代码就好办了，因为商品数据就存储在那庞杂的代码中。</DIV>
<DIV><BR>这很简单，我接着写了如下函数：</DIV>
<DIV>&nbsp;</DIV>
<DIV><STRONG>function getBody(infopageurl)<BR></STRONG>'功能：取得指定网址的html代码<BR>'参数：infopageurl 网页地址</DIV>
<DIV><STRONG>if infopageurl&lt;&gt;"" then<BR>&nbsp;dim xmlHttp<BR>&nbsp;set xmlHttp=server.createobject("MSXML2.XMLHTTP")</STRONG>‘声明XMLHTTP对象</DIV>
<DIV><STRONG>&nbsp;xmlHttp.open "GET",infopageurl,false<BR>&nbsp;xmlHttp.send</STRONG>’上面这两就句就是调用的形式，调用后程序会堵塞在send这句，直到内容被返回。<BR><STRONG>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; getBody=BytesToBstr(xmlhttp.responsebody,"GB2312")</STRONG>‘然后通过xmlhttp.responsebody属性将返回内容读出，这里用到一个BytesToBstr函数将在后面说明。</DIV>
<DIV><STRONG>&nbsp;set xmlHttp=nothing<BR>end if&nbsp;<BR>end function</STRONG></DIV>
<DIV><STRONG></STRONG>&nbsp;</DIV>
<DIV>关于BytesToBstr,开始返回的结果没有经过这个函数处理，结果返回的汉字是一堆乱码。什么原因就不用深究了。我到<A href="http://www.chinaz.com/"><FONT color=#0d5d91>www.chinaz.com</FONT></A>下载了几个”小偷’的程序，发现里面不约而同的都含有这个函数。大概就是用adodb.stream对结果字符进行了转换。我把它加到我的函数里结果就正常了。</DIV>
<DIV>&nbsp;</DIV>
<DIV><STRONG>Function BytesToBstr(body,Cset) </STRONG></DIV>
<DIV><STRONG>&nbsp;dim objstream <BR>&nbsp;<BR>&nbsp;set objstream = Server.CreateObject("adodb.stream") <BR>&nbsp;<BR>&nbsp;objstream.Type = 1 <BR>&nbsp;<BR>&nbsp;objstream.Mode = 3 <BR>&nbsp;<BR>&nbsp;objstream.Open <BR>&nbsp;<BR>&nbsp;objstream.Write body <BR>&nbsp;<BR>&nbsp;objstream.Position = 0 <BR>&nbsp;<BR>&nbsp;objstream.Type = 2 <BR>&nbsp;<BR>&nbsp;objstream.Charset = Cset <BR>&nbsp;<BR>&nbsp;BytesToBstr = objstream.ReadText <BR>&nbsp;<BR>&nbsp;objstream.Close <BR>&nbsp;<BR>&nbsp;set objstream = nothing </STRONG></DIV>
<DIV><STRONG>End Function</STRONG></DIV>
<DIV><BR>html代码取回来了，我们怎么从中取得需要的数据？答案是正则表达式。</DIV>
<DIV>这里是关于正则表达式的参考<BR><A href="http://www.51windows.net/pages/vbscript/html/reconIntroductionToRegularExpressions.htm"><FONT color=#0d5d91>http://www.51windows.net/pages/vbscript/html/reconIntroductionToRegularExpressions.htm</FONT></A></DIV>
<DIV><FONT color=#0d5d91></FONT>&nbsp;</DIV>
<DIV>正则表达达式就象是一种简单的语言。它用一些特殊的字符模糊地描述一个字符串。然后可以通过程序去检查一个字符串中是否包含你描述的那种字符串，还可以将你描述的字符从一个字符串中取出，这里我们就是利用这个功能来获取需要的数据。</DIV>
<DIV>&nbsp;</DIV>
<DIV>举起例子比较容易理解：</DIV>
<DIV><STRONG><FONT color=#3366ff>*</FONT> 匹配前面的子表达式零次或多次。例如，zo*（正则表达式） 能匹配 z 、 zoo、zooooo、zoooooooooo<BR><FONT color=#3366ff>+</FONT> 匹配前面的子表达式一次或多次。例如，zo+ 能匹配 zo 以及 zoo，但不能匹配 "z"。<BR><FONT color=#3366ff>\d</FONT> 匹配一个数字字符。等价于 [0-9]。&nbsp; 例如， \d+ 可以匹配 1，123，987<FONT color=#000000>6</FONT></STRONG></DIV>
<DIV>
<TABLE cellSpacing=0>
<TBODY>
<TR vAlign=top>
<TD width="16%"><STRONG><FONT color=#3366ff>.</FONT></STRONG></TD>
<TD width="84%"><STRONG>匹配除 "\n" 之外的任何单个字符。</STRONG></TD></TR></TBODY></TABLE></DIV>
<DIV><FONT color=#3366ff>?</FONT> <STRONG>当该字符紧跟在任何一个其他限制符 (*, +, ?, {n}, {n,}, {n,m}) 后面时，匹配模式是非贪婪的。非贪婪模式尽可能少的匹配所搜索的字符串，而默认的贪婪模式则尽可能多的匹配所搜索的字符串。例如，对于字符串 "oooo"，'o+?' 将匹配单个 "o"，而 'o+' 将匹配所有 'o'。</STRONG> </DIV>
<DIV>&nbsp;</DIV>
<DIV>下面要做的就是分析商品数据在html代码中存放的特征，然后写出正则表达式将其取出。<BR>例如，joyo商品的市场价格数据在html代码中是这样存储的“市场价：15.00元”，要做的是把以“市场价：”开头，“元”结尾之间的数值取出。下面函数就实现了这个功能：</DIV>
<DIV>&nbsp;</DIV>
<DIV><STRONG>function Topic(sHtmlcode)<BR></STRONG>'功能：返回joyo.com商品页面的市场价格数值<BR>'参数：shtmlcode 商品页的html代码</DIV>
<DIV><STRONG>Set regEx = New RegExp</STRONG>'建立使用正则表达式的对象</DIV>
<DIV><STRONG>regEx.IgnoreCase =true<BR>regEx.Global = True<BR>regEx.Pattern ="市场价：(.+?)元"设置表达式</STRONG></DIV>
<DIV><STRONG>Set Matches = regEx.Execute(shtmlcode)</STRONG>'执行表达式将所有符合描述的字符传存放到一个集合里。</DIV>
<DIV><STRONG>for each sMatch in Matches<BR>Topic=sMatch.SubMatches(0)</STRONG>'submatches(0)带表第一个子匹配,既小括号中的数值<BR><STRONG>exit for<BR>next&nbsp;<BR>set regEx=nothing<BR>end function</STRONG></DIV>
<DIV><STRONG></STRONG>&nbsp;</DIV>
<DIV>其他的数据也用同样的方法取得。写正则表达式是一个很有趣而且很复杂的工作。期间我遇到写不出来的，就去CSDN.net的论坛去提问，总是可以得到帮助。</DIV>
<DIV>&nbsp;</DIV>
<DIV>还有一点要思考的是：是不是这个表达式对所有的商品页面都适用。如果所有的商品都是用一个asp程序显示那就可以，但是joyo.com不是，它的不同分类中html代码的格式是不同的，所以我们要写几个正则表达式来分别匹配不同形式的数据（比如有些页面中市场价格是这样存储的“市场价：&lt;b&gt;15.00&lt;/b&gt;元"）。</DIV>
<DIV><BR>有了这些函数我们就可以用给定的商品网页地址取得相应的数据了。但是这些网站的商品一般都有万余种，如何获取这些地址就不是那么容易了。这个过程因站而异，这也是真正需要“小偷”智慧的工作之一。</DIV>
<DIV>&nbsp;</DIV>
<DIV>拿joyo.com进行分析。进入首页之后我发现里面有个”产品搜索“，选择“所有类别”，关键字置空，点击那个”GO!"检索出了21684条记录。这应该就是joyo.com的所有商品信息了，来的太容易我简直不敢相信。</DIV>
<DIV><BR>检索页上包含有10条商品的连接，用正则取得后，再取得转向后10条记录（即下一页）的连接。如此循环就会得出所有商品信息。我用access建了一个表来存放它们。编好了程序挂到机器上就睡觉去了。</DIV>
<DIV><BR>这是一个检索结果页的连接：<BR><A href="http://www.joyo.com/ProdSearch/prodsearch.asp?kind=&amp;limitBefore=10&amp;vname=&amp;sorttype=undefined&amp;uid=u5swcqykpzsis0qaiwg79sg5u"><FONT color=#0d5d91>http://www.joyo.com/ProdSearch/prodsearch.asp?kind=&amp;limitBefore=10&amp;vname=&amp;sorttype=undefined&amp;uid=u5swcqykpzsis0qaiwg79sg5u</FONT></A><BR>其中limitBefore=10 当前页第一条记录前有10条记录，即这一页的第一条是总的第11条记录。</DIV>
<DIV>&nbsp;</DIV>
<DIV>第二天兴奋地来到机器上一看，发现记录只有700多条。很郁闷，程序我没加容错处理因为我发现vbscript的错误处理比vb中的还要简略。似乎连on error goto LABEL都不可以使用。我在检索页点来点去希望找出错误的根源，结果发现当其中limitBefore大于750的时候后面就没有记录了。原来是这样。joyo.com的程序员没有让我们这么容易的得到所有数据。这条路是不能走了。</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>下面我开始分析检索结果中商品信息页面的连接：<BR><A href="http://www.joyo.com/shop/shop_product.asp?uid=u5swcqykpzsis0qaiwg79sg5u&amp;prodid=bkbk507440"><FONT color=#0d5d91>http://www.joyo.com/shop/shop_product.asp?uid=u5swcqykpzsis0qaiwg79sg5u&amp;prodid=bkbk507440</FONT></A><BR>经分析 prodid=bkbk507440 是这个产品的唯一标识，bkbk表示该产品的所属分类“图书”</DIV>
<DIV>&nbsp;</DIV>
<DIV>这是一些其他的主要分类标识：<BR>bkbk 图书<BR>bkmu 音乐<BR>itit 数码<BR>bkbh 日用<BR>itrj 数码产品<BR>bkgm 游戏<BR>bkys 影视</DIV>
<DIV>&nbsp;</DIV>
<DIV>只要我遍历所有的prodid然后找出存在的商品页面就可以了。然而怎么判断该prodid是否存在呢，我在地址栏上胡乱打了一个prodid返回了出错结果页面。</DIV>
<DIV>&nbsp;</DIV>
<DIV><A href="http://www.joyo.com/errormsg.asp?uid=u5swcqykpzsis0qaiwg79smuw&amp;err=GET%C7%EB%C7%F3%B5%C4%C9%CC%C6%B7ID%B2%BB%B4%E6%D4%DA%A3%AC%B2%D9%D7%F7%CE%DE%B7%A8%BC%CC%D0%F8%A3%A1"><FONT color=#0d5d91>http://www.joyo.com/errormsg.asp?uid=u5swcqykpzsis0qaiwg79smuw&amp;err=GET%C7%EB%C7%F3%B5%C4%C9%CC%C6%B7ID%B2%BB%B4%E6%D4%DA%A3%AC%B2%D9%D7%F7%CE%DE%B7%A8%BC%CC%D0%F8%A3%A1</FONT></A></DIV>
<DIV><FONT color=#0d5d91></FONT>&nbsp;</DIV>
<DIV>出错页上有一张红色的“警钟”图案，我估计正常的页面上是不可能包含此图片的。于是以此作为判断prodid是否存在的依据。遍历所有prodid,如果在返回结果html中发现“警钟”图片则不做处理，否则就从页面中取出需要的信息。</DIV>
<DIV><BR>遍历6位的prodid是个漫长的过程，粗略的估算，如果每个操作用时1秒的话,则最少需要999999次循,环即999999秒（999999/3600=277多小时）。这显然是太长了，于是我又做了一些优化，发现第一位数字只在0-5之间变化，第二为数字只在0-1之间变化。这样大大的缩短了时间(519999/3600=144多小时),实际的时间更乐观。</DIV>
<DIV>&nbsp;</DIV>
<DIV>经过几天的调试终于把图书分类下载完了，接下来我又接着优化程序，做一个更有效率的“小偷”。</DIV></TD></TR></TBODY></TABLE><img src ="http://www.cnitblog.com/aiut/aggbug/4642.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/aiut/" target="_blank">登陆不起啦</a> 2005-11-17 21:57 <a href="http://www.cnitblog.com/aiut/archive/2005/11/17/4642.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转]获取远程服务器数据（asp，adodb.stream，保存远程图片，XMLHTTP）  作者：blue1019</title><link>http://www.cnitblog.com/aiut/archive/2005/11/17/4641.html</link><dc:creator>登陆不起啦</dc:creator><author>登陆不起啦</author><pubDate>Thu, 17 Nov 2005 13:53:00 GMT</pubDate><guid>http://www.cnitblog.com/aiut/archive/2005/11/17/4641.html</guid><wfw:comment>http://www.cnitblog.com/aiut/comments/4641.html</wfw:comment><comments>http://www.cnitblog.com/aiut/archive/2005/11/17/4641.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnitblog.com/aiut/comments/commentRss/4641.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/aiut/services/trackbacks/4641.html</trackback:ping><description><![CDATA[<TABLE class="fixedTable blogpost" cellSpacing=0 width="100%" border=0>
<TBODY>
<TR>
<TD vAlign=top><SPAN class=bold id=LastMDatecns!1pvHzJ2FFuxbZKKCb2_fpGcA!305><STRONG>作者：blue1019<BR>来源：<A href="http://spaces.msn.com/members/blue1019/Blog/cns!1pvHzJ2FFuxbZKKCb2_fpGcA!305.entry">http://spaces.msn.com/members/blue1019/Blog/cns!1pvHzJ2FFuxbZKKCb2_fpGcA!305.entry</A><BR><BR>10月10日</STRONG></SPAN></TD></TR>
<TR>
<TD height=4><STRONG></STRONG></TD></TR>
<TR>
<TD class=blackline><STRONG></STRONG></TD></TR>
<TR>
<TD height=4><STRONG></STRONG></TD></TR>
<TR>
<TD class=ellipse><SPAN class=bvTitle id=subjcns!1pvHzJ2FFuxbZKKCb2_fpGcA!305><STRONG>获取远程服务器数据（asp，adodb.stream，保存远程图片，XMLHTTP）</STRONG></SPAN></TD></TR>
<TR>
<TD class=bvh8><STRONG></STRONG></TD></TR>
<TR>
<TD id=msgcns!1pvHzJ2FFuxbZKKCb2_fpGcA!305>
<DIV>本文章对使用xmlhttp下载其他服务器信息的技术做了进一步的研究,如不熟悉请先阅读</DIV>
<DIV>&nbsp;</DIV>
<DIV><SPAN>小偷是怎样炼成的</SPAN></DIV>
<DIV><A href="http://spaces.msn.com/members/blue1019/Blog/cns!1pvHzJ2FFuxbZKKCb2_fpGcA!243.entry"><FONT color=#0d5d91>http://spaces.msn.com/members/blue1019/Blog/cns!1pvHzJ2FFuxbZKKCb2_fpGcA!243.entry</FONT></A></DIV>
<DIV><FONT color=#0d5d91></FONT>&nbsp;</DIV>
<DIV>关于XMLHTTP的细节可以参考</DIV>
<DIV><A href="http://www.channel7.cn/2004/11-18/14458.html"><FONT color=#0d5d91>http://www.channel7.cn/2004/11-18/14458.html</FONT></A></DIV>
<DIV><FONT color=#0d5d91></FONT>&nbsp;</DIV>
<DIV>关于adodb.stream的细节可以参考</DIV>
<DIV><A href="http://www.daima.com.cn/Info/32/Info22138/"><FONT color=#0d5d91>http://www.daima.com.cn/Info/32/Info22138/</FONT></A></DIV>
<DIV><FONT color=#0d5d91></FONT>&nbsp;</DIV>
<DIV><FONT color=#0d5d91></FONT>&nbsp;</DIV>
<DIV>下面重新注释了BytesToBstr函数,它的作用是把由xmlhttp.responsebody返回的字节数组转换成文本字符串,如果数据要用做屏幕输入则必须转换否则汉字会出现乱码.</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;Function BytesToBstr(body)<BR>&nbsp;&nbsp;'Cset:GB2312 UTF-8<BR>&nbsp;&nbsp;dim objstream <BR>&nbsp;&nbsp;set objstream = Server.CreateObject("adodb.stream") <BR>&nbsp;&nbsp;with objstream<BR>&nbsp;&nbsp;&nbsp;.Type = 1 '<STRONG>设置返回数据类型为二进制<BR></STRONG>&nbsp;&nbsp;&nbsp;.Mode = 3 '打开模式为读写<BR>&nbsp;&nbsp;&nbsp;.Open&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;.Write body&nbsp; '<STRONG>将指定的数据装入对像中 body为内容<BR></STRONG>&nbsp;&nbsp;&nbsp;.Position = 0 '<STRONG>指定对像内数据的当前指针<BR></STRONG>&nbsp;&nbsp;&nbsp;.Type = 2&nbsp; '<STRONG>设置返回数据类型为文本<BR></STRONG>&nbsp;&nbsp;&nbsp;.Charset = Cset&nbsp; '<STRONG>设定字符集类型</STRONG><BR>&nbsp;&nbsp;&nbsp;BytesToBstr = .ReadText '<STRONG>取对象内的文本<BR></STRONG>&nbsp;&nbsp;&nbsp;.Close <BR>&nbsp;&nbsp;end with<BR>&nbsp;&nbsp;set objstream = nothing <BR>&nbsp;End Function </DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>获取其他服务器的数据和获取文本是一个道理，通过图片的url获取图片的数据处理,只是保存的时候不需要把它转换成字符串了。这里利用adodb.stream的SaveToFile方法将其保存在本地服务器上。</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;Public function saveimage(tofile)<BR>&nbsp;&nbsp;dim objStream,imgs<BR>&nbsp;&nbsp;imgs=getBody(sUrl)'<STRONG>取得图片的具休内容的过程<BR></STRONG>&nbsp;&nbsp;Set objStream = Server.CreateObject("ADODB.Stream")'<STRONG>建立ADODB.Stream对象，必须要ADO 2.5以上版本<BR></STRONG>&nbsp;&nbsp;with objStream<BR>&nbsp;&nbsp;&nbsp;.Type =1'<STRONG>以二进制模式打开</STRONG><BR>&nbsp;&nbsp;&nbsp;.Open<BR>&nbsp;&nbsp;&nbsp;.write imgs'<STRONG>将字符串内容写入缓冲</STRONG><BR>&nbsp;&nbsp;&nbsp;.SaveToFile server.mappath(tofile),2'<STRONG>将缓冲的内容写入文件</STRONG><BR>&nbsp;&nbsp;&nbsp;.Close()<BR>&nbsp;&nbsp;end with&nbsp;<BR>&nbsp;&nbsp;set objstream=nothing<BR>&nbsp;end function</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>实现了保存文本数据和二进制数据，那就无所不能了*^_^*</DIV>
<DIV>&nbsp;</DIV>
<DIV>附一个包括简单功能类完整代码：</DIV>
<DIV>---------------------------------------------------------------------------</DIV>
<DIV><FONT color=#000080>Class xhttp</FONT></DIV>
<DIV><FONT color=#000080>&nbsp;private cset,sUrl</FONT></DIV>
<DIV><FONT color=#000080>&nbsp;Private Sub Class_Initialize()<BR>&nbsp;&nbsp;cset="UTF-8"<BR>&nbsp;end sub<BR>&nbsp;<BR>&nbsp;<BR>&nbsp;Private Sub Class_Terminate()<BR>&nbsp;End Sub</FONT></DIV>
<DIV><BR><FONT color=#000080>&nbsp;Public Property LET URL(theurl)<BR>&nbsp;&nbsp;sUrl=theurl<BR>&nbsp;end property<BR>&nbsp;<BR>&nbsp;public property GET BasePath()<BR>&nbsp;&nbsp;BasePath=mid(sUrl,1,InStrRev(sUrl,"/")-1)<BR>&nbsp;end property<BR>&nbsp;<BR>&nbsp;public property GET FileName()<BR>&nbsp;&nbsp;FileName=mid(sUrl,InStrRev(sUrl,"/")+1)<BR>&nbsp;end property</FONT></DIV>
<DIV><FONT color=#000080>&nbsp;public property GET Html()<BR>&nbsp;&nbsp;Html=BytesToBstr(getBody(sUrl))<BR>&nbsp;end property</FONT></DIV>
<DIV><FONT color=#000080>&nbsp;private Function BytesToBstr(body)<BR>&nbsp;&nbsp;'Cset:GB2312 UTF-8<BR>&nbsp;&nbsp;dim objstream <BR>&nbsp;&nbsp;set objstream = Server.CreateObject("adodb.stream") <BR>&nbsp;&nbsp;with objstream<BR>&nbsp;&nbsp;&nbsp;.Type = 1 '设置返回数据类型为二进制<BR>&nbsp;&nbsp;&nbsp;.Mode = 3 '打开模式为读写<BR>&nbsp;&nbsp;&nbsp;.Open&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;.Write body&nbsp; '将指定的数据装入对像中 body为内容<BR>&nbsp;&nbsp;&nbsp;.Position = 0 '指定对像内数据的当前指针<BR>&nbsp;&nbsp;&nbsp;.Type = 2&nbsp; '设置返回数据类型为文本<BR>&nbsp;&nbsp;&nbsp;.Charset = Cset&nbsp; '设定字符集类型<BR>&nbsp;&nbsp;&nbsp;BytesToBstr = .ReadText '取对象内的文本<BR>&nbsp;&nbsp;&nbsp;.Close <BR>&nbsp;&nbsp;end with<BR>&nbsp;&nbsp;set objstream = nothing <BR>&nbsp;End Function </FONT></DIV>
<DIV><BR><FONT color=#000080>&nbsp;private function getBody(surl)<BR>&nbsp;&nbsp;dim xmlHttp<BR>&nbsp;&nbsp;set xmlHttp=server.createobject("MSXML2.XMLHTTP")<BR>&nbsp;&nbsp;xmlHttp.open "GET",surl,false<BR>&nbsp;&nbsp;xmlHttp.send<BR>&nbsp;&nbsp;if xmlHttp.readystate&lt;&gt;4 then <BR>&nbsp;&nbsp;&nbsp;exit function<BR>&nbsp;&nbsp;end if<BR>&nbsp;&nbsp; getBody=xmlhttp.responsebody<BR>&nbsp;&nbsp;set xmlHttp=nothing<BR>&nbsp;end function<BR>&nbsp;<BR>&nbsp;<BR>&nbsp;Public function saveimage(tofile)<BR>&nbsp;&nbsp;dim objStream,imgs<BR>&nbsp;&nbsp;imgs=getBody(sUrl)'取得图片的具休内容的过程<BR>&nbsp;&nbsp;Set objStream = Server.CreateObject("ADODB.Stream")'建立ADODB.Stream对象，必须要ADO 2.5以上版本<BR>&nbsp;&nbsp;with objStream<BR>&nbsp;&nbsp;&nbsp;.Type =1'以二进制模式打开<BR>&nbsp;&nbsp;&nbsp;.Open<BR>&nbsp;&nbsp;&nbsp;.write imgs'将字符串内容写入缓冲<BR>&nbsp;&nbsp;&nbsp;.SaveToFile server.mappath(tofile),2'-将缓冲的内容写入文件<BR>&nbsp;&nbsp;&nbsp;.Close()<BR>&nbsp;&nbsp;end with&nbsp;<BR>&nbsp;&nbsp;set objstream=nothing<BR>&nbsp;end function<BR>&nbsp;<BR>end class&nbsp;</FONT></DIV>
<DIV><FONT color=#000080></FONT>&nbsp;</DIV>
<DIV><FONT color=#000080></FONT>&nbsp;</DIV>
<DIV><FONT color=#000080>TEST:</FONT></DIV>
<DIV><FONT color=#000080>dim o </FONT></DIV>
<DIV><FONT color=#000080>set o=new xhttp</FONT></DIV>
<DIV><FONT color=#000080>o.url=</FONT><A href="http://www.baidu.com/img/logo-yy.gif"><FONT color=#000080>"http://www.baidu.com/img/logo-yy.gif</FONT></A><FONT color=#000080>"</FONT></DIV>
<DIV><FONT color=#000080>o.saveimage "blue.gif"</FONT></DIV>
<DIV><FONT color=#000080>set o=nothing</FONT></DIV></TD></TR></TBODY></TABLE><img src ="http://www.cnitblog.com/aiut/aggbug/4641.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/aiut/" target="_blank">登陆不起啦</a> 2005-11-17 21:53 <a href="http://www.cnitblog.com/aiut/archive/2005/11/17/4641.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>.net中xmlhttp下载文件的方法参考[转载]</title><link>http://www.cnitblog.com/aiut/archive/2005/11/17/4639.html</link><dc:creator>登陆不起啦</dc:creator><author>登陆不起啦</author><pubDate>Thu, 17 Nov 2005 13:24:00 GMT</pubDate><guid>http://www.cnitblog.com/aiut/archive/2005/11/17/4639.html</guid><wfw:comment>http://www.cnitblog.com/aiut/comments/4639.html</wfw:comment><comments>http://www.cnitblog.com/aiut/archive/2005/11/17/4639.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/aiut/comments/commentRss/4639.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/aiut/services/trackbacks/4639.html</trackback:ping><description><![CDATA[<P>来源：<A href="http://www.caspnet.com.cn/blog/post/111.html">http://www.caspnet.com.cn/blog/post/111.html</A><BR><BR>下面为完整的源代码</P>
<P>
<TABLE style="BORDER-RIGHT: #cccccc 1px dotted; TABLE-LAYOUT: fixed; BORDER-TOP: #cccccc 1px dotted; BORDER-LEFT: #cccccc 1px dotted; BORDER-BOTTOM: #cccccc 1px dotted" cellSpacing=0 cellPadding=6 width="95%" align=center border=0>
<TBODY>
<TR>
<TD style="WORD-WRAP: break-word" bgColor=#f3f3f3><FONT style="FONT-WEIGHT: bold; COLOR: #990000">以下是引用片段：</FONT><BR>&lt;%@&nbsp;Page&nbsp;language="c#"%&gt;&nbsp; <BR>&lt;%@import&nbsp;namespace=MSXML2%&gt;&nbsp; <BR>&lt;script&nbsp;language="c#"&nbsp;runat="server"&gt;&nbsp; <BR>private&nbsp;void&nbsp;Page_Load(object&nbsp;sender,&nbsp;System.EventArgs&nbsp;e)&nbsp; <BR>{&nbsp; <BR>string&nbsp;Url&nbsp;=&nbsp;"/blog/upload/20056222116262.gif";&nbsp; <BR>string&nbsp;StringFileName&nbsp;=&nbsp;Url.Substring(Url.LastIndexOf("/")&nbsp;+&nbsp;1);&nbsp; <BR>string&nbsp;StringFilePath&nbsp;=&nbsp;Request.PhysicalApplicationPath;&nbsp; <BR>if(!StringFilePath.EndsWith("/"))&nbsp;StringFilePath&nbsp;+=&nbsp;"/";&nbsp; <BR>MSXML2.XMLHTTP&nbsp;_xmlhttp&nbsp;=&nbsp;new&nbsp;MSXML2.XMLHTTPClass();&nbsp; <BR>_xmlhttp.open("GET",Url,false,null,null);&nbsp; <BR>_xmlhttp.send("");&nbsp; <BR>if(&nbsp;_xmlhttp.readyState&nbsp;==&nbsp;4&nbsp;)&nbsp; <BR>{&nbsp; <BR>if(System.IO.File.Exists(StringFilePath&nbsp;+&nbsp;StringFileName))&nbsp; <BR>System.IO.File.delete(StringFilePath&nbsp;+&nbsp;StringFileName);&nbsp; <BR>System.IO.FileStream&nbsp;fs&nbsp;=&nbsp;new&nbsp;System.IO.FileStream(StringFilePath&nbsp;+&nbsp;StringFileName,&nbsp;System.IO.FileMode.createNew);&nbsp; <BR>System.IO.BinaryWriter&nbsp;w&nbsp;=&nbsp;new&nbsp;System.IO.BinaryWriter(fs);&nbsp; <BR>w.Write((byte[])_xmlhttp.responseBody);&nbsp; <BR>w.Close();&nbsp; <BR>fs.Close();&nbsp; <BR>Response.Write&nbsp;("文件已经得到。&lt;br&gt;&lt;a&nbsp;href=’"&nbsp;+&nbsp;Request.ApplicationPath&nbsp;+&nbsp;"\\"&nbsp;+&nbsp;StringFileName&nbsp;+"’&nbsp;target=’_blank’&gt;");&nbsp; <BR>Response.Write&nbsp;("查看"&nbsp;+&nbsp;StringFileName&nbsp;+&nbsp;"&lt;/a&gt;");&nbsp; <BR>}&nbsp; <BR>else&nbsp; <BR>//Response.Write&nbsp;(_xmlhttp.statusText);&nbsp; <BR>Response.End();&nbsp; <BR>}&nbsp; <BR>&lt;/script&gt;&nbsp;</TD></TR></TBODY></TABLE></P><BR>
<P><FONT color=#1111ee></FONT>&nbsp;</P>
<P><FONT color=#1111ee></FONT>&nbsp;</P>
<P><FONT color=#1111ee>//试分析 .NET 下用MSXML远程下载文件跟处理方法</FONT></P>
<P><FONT color=#1111ee>//声明为 C#语言</FONT><BR>&lt;%@ Page language="c#"%&gt; </P>
<P><FONT color=#1111ee>//导入MSXML2空间，表示下面要用到这个空间里的一些内容</FONT><BR>&lt;%@import namespace=MSXML2%&gt; <BR><FONT color=#1111ee>//语言C# 运行在服务器端</FONT><BR>&lt;script language="c#" runat="server"&gt; <BR></P>
<P>private void Page_Load(object sender, System.EventArgs e) <BR>{ </P>
<P><FONT color=#1111ee>//定义变量&nbsp; Url 为一个绝对目录地址</FONT><BR>string Url = "/blog/upload/20056222116262.gif";</P>
<P><FONT color=#1111ee>//定义变量&nbsp;取得以 / 为分隔符的&nbsp;最后那个数组数据&nbsp; 得到&nbsp;20056222116262.gif<BR></FONT>string StringFileName = Url.Substring(Url.LastIndexOf("/") + 1); </P>
<P><FONT color=#1111ee>//定义变量，得到当前文件的物理路径</FONT><BR>string StringFilePath = Request.PhysicalApplicationPath; </P>
<P><FONT color=#1111ee>//如果路径最后的字符不为 / 则加上 /</FONT><BR>if(!StringFilePath.EndsWith("/")) StringFilePath += "/"; </P>
<P><FONT color=#1111ee>//申请 XMLHTTP对象</FONT></P>
<P>MSXML2.XMLHTTP _xmlhttp = new MSXML2.XMLHTTPClass(); </P>
<P><FONT color=#1111ee>// 用 GET方式　向URL地址　需要等待服务器回应 False<BR></FONT>_xmlhttp.open("GET",Url,false,null,null); </P>
<P><FONT color=#1111ee>//发送请求</FONT><BR>_xmlhttp.send("");</P>
<P><FONT color=#1111ee>//如果返回的是　服务器回应完毕，文件已经下载成功　则进入下一步</FONT>&nbsp;<BR>if( _xmlhttp.readyState == 4 ) <BR>{ </P>
<P><FONT color=#1111ee>//查看　当前路径，当前文件名的　有没有存在这个文件</FONT><BR>if(System.IO.File.Exists(StringFilePath + StringFileName)) </P>
<P><FONT color=#1111ee>//如果存在就删除</FONT><BR>System.IO.File.delete(StringFilePath + StringFileName); </P>
<P><FONT color=#1111ee>//创建文件流格式</FONT><BR>System.IO.FileStream fs = new System.IO.FileStream(StringFilePath + StringFileName, System.IO.FileMode.createNew); </P>
<P><FONT color=#1111ee>//用二进制模式打开<BR></FONT>System.IO.BinaryWriter w = new System.IO.BinaryWriter(fs); </P>
<P><FONT color=#1111ee>//写入到文件中。。内容为　XMLHTTP抓取的数据。</FONT><BR>w.Write((byte[])_xmlhttp.responseBody); </P>
<P><FONT color=#1111ee>//关闭对像　<BR></FONT>w.Close(); <BR>fs.Close(); </P>
<P><BR>Response.Write ("文件已经得到。&lt;br&gt;&lt;a href='" + Request.ApplicationPath + "\\" + StringFileName +"' target='_blank'&gt;"); <BR>Response.Write ("查看" + StringFileName + "&lt;/a&gt;"); <BR>} <BR>else </P>
<P><FONT color=#1111ee>//如果采集不到数据，则停止一切操作<BR></FONT>//Response.Write (_xmlhttp.statusText); <BR>Response.End(); <BR>} <BR>&lt;/script&gt; <BR></P><img src ="http://www.cnitblog.com/aiut/aggbug/4639.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/aiut/" target="_blank">登陆不起啦</a> 2005-11-17 21:24 <a href="http://www.cnitblog.com/aiut/archive/2005/11/17/4639.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>XMLHTTP 对象及其方法（转）</title><link>http://www.cnitblog.com/aiut/archive/2005/10/15/3313.html</link><dc:creator>登陆不起啦</dc:creator><author>登陆不起啦</author><pubDate>Sat, 15 Oct 2005 07:39:00 GMT</pubDate><guid>http://www.cnitblog.com/aiut/archive/2005/10/15/3313.html</guid><wfw:comment>http://www.cnitblog.com/aiut/comments/3313.html</wfw:comment><comments>http://www.cnitblog.com/aiut/archive/2005/10/15/3313.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/aiut/comments/commentRss/3313.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/aiut/services/trackbacks/3313.html</trackback:ping><description><![CDATA[MSXML中提供了Microsoft.XMLHTTP对象，能够完成从数据包到Request对象的转换以及发送任务。 <BR>创建XMLHTTP对象的语句如下： <BR><BR><FONT color=#0000ff>Set objXML = CreateObject(Msxml2.XMLHTTP) 或 <BR>Set objXML = CreateObject(“Microsoft.XMLHTTP”) <BR>' Or, for version 3.0 of XMLHTTP, use: <BR>' Set xml = Server.CreateObject(MSXML2.ServerXMLHTTP)</FONT> <BR><BR>对象创建后调用<FONT color=#ff1493>Open</FONT>方法对Request对象进行初始化，语法格式为： <BR>poster.open http-method, url, async, userID, password <BR><BR>Open方法中包含了5个参数，前三个是必要的，后两个是可选的(在服务器需要进行身份验证时提供)。参数的含义如下所示： <BR><FONT color=#ff0000>http-method</FONT>： HTTP的通信方式，比如GET或是 POST <BR><FONT color=#ff0000>url</FONT>： 接收XML数据的服务器的URL地址。通常在URL中要指明 ASP或CGI程序 <BR><FONT color=#ff0000>async</FONT>： 一个布尔标识，说明请求是否为异步的。如果是异步通信方式(true)，客户机就不等待服务器的响应；如果是同步方式(false)，客户机就要等到服务器返回消息后才去执行其他操作 <BR><FONT color=#ff0000>userID</FONT> 用户ID，用于服务器身份验证 <BR><FONT color=#ff0000>password</FONT> 用户密码，用于服务器身份验证&amp;nbsp; <BR><BR><BR>XMLHTTP对象的<FONT color=#ff1493>Send</FONT>方法 <BR>用Open方法对Request对象进行初始化后，调用Send方法发送XML数据： <BR>poster.send XML-data <BR><BR>Send方法的参数类型是Variant，可以是字符串、DOM树或任意数据流。发送数据的方式分为同步和异步两种。在异步方式下，数据包一旦发送完毕，就结束Send进程，客户机执行其他的操作；而在同步方式下，客户机要等到服务器返回确认消息后才结束Send进程。 <BR><BR>XMLHTTP对象中的readyState属性能够反映出服务器在处理请求时的进展状况。客户机的程序可以根据这个状态信息设置相应的事件处理方法。属性值及其含义如下表所示： <BR>值 说明 <BR>0 Response对象已经创建，但XML文档上载过程尚未结束 <BR>1 XML文档已经装载完毕 <BR>2 XML文档已经装载完毕，正在处理中 <BR>3 部分XML文档已经解析 <BR>4 文档已经解析完毕，客户端可以接受返回消息 <BR><BR>客户机处理响应信息 <BR>客户机接收到返回消息后，进行简单的处理，基本上就完成了C/S之间的一个交互周期。客户机接收响应是通过XMLHTTP对象的属性实现的： <BR>● responseTxt：将返回消息作为文本字符串； <BR>● responseXML：将返回消息视为XML文档，在服务器响应消息中含有XML数据时使用； <BR>● responseStream：将返回消息视为Stream对象。 <img src ="http://www.cnitblog.com/aiut/aggbug/3313.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/aiut/" target="_blank">登陆不起啦</a> 2005-10-15 15:39 <a href="http://www.cnitblog.com/aiut/archive/2005/10/15/3313.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>