在使用ajax的时候,我们无法跨域获取不属于自己的服务器的数据,故引出了这么一种方法来辗转获取:
1、向本域中的网页请求数据,包含一个网址信息
2、被请求的本域的网页中的asp代码向跨域的服务器请求数据,然后返回给本域中的asp文件
代码:
|
1
2
3
4
5
6
7
8
9
10
11
12
|
Function getHtml(url) ‘以HTML格式备份 Set xh = CreateObject("Microsoft.XMLHTTP") xh.Open
"GET",url,0 xh.Send() Set MyStream=CreateObject("Adodb.Stream")
MyStream.Type =
2 MyStream.Open
MyStream.WriteText xh.responseText MyStream.Position =
0 getHtml=MyStream.ReadText MyStream.CloseEnd Function |
原文:http://blog.csdn.net/sxw3718401/article/details/39495283