有一个关于MSXML2.XMLHTTP的问题求教!

ppxstar 2006-10-11 08:24:15
大家好!

我用MSXML2.XMLHTTP来读取一个网页的代码
但是那个网页有下面一段代码


<SCRIPT language=javascript>
<!--
if(window.name!='sname')
{
top.location="http://www.sname.com/index.html"
}
var state=0
window.resizeTo(620,465);
window.moveTo(140,90);
//-->
</SCRIPT>


结果我读取的页面成了转向的http://www.sname.com/index.html
请问如何饶过这一句,直接读取我想要的页面呢?
...全文
207 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
ppxstar 2006-10-14
  • 打赏
  • 举报
回复
好的,我明白了,你给我很大提示
ppxstar 2006-10-14
  • 打赏
  • 举报
回复
你这个我看的不是很明白呀!
我之所以读不到数据是因为我要读取的网页内有
<SCRIPT language=javascript>
<!--
if(window.name!='sname')
{
top.location="http://www.sname.com/index.html"
}
var state=0
window.resizeTo(620,465);
window.moveTo(140,90);
//-->
</SCRIPT>

这样的代码,如何能饶过它呢?
什么都不能 2006-10-12
  • 打赏
  • 举报
回复
是服务代理,你要读取哪个页面的内容?我来试一下
ppxstar 2006-10-12
  • 打赏
  • 举报
回复
代码就是很普通的读取,已经成功的读取很多了,就这一个页面,因为有一个判断,所以读不成功。

Function GetHttpPage(HttpUrl)
If IsNull(HttpUrl)=True Or HttpUrl="$False$" Then
GetHttpPage="$False$"
Exit Function
End If
Dim Http
Set Http=server.createobject("MSXML2.XMLHTTP")
Http.open "GET",HttpUrl,False
Http.Send()
If Http.Readystate<>4 then
Set Http=Nothing
GetHttpPage="$False$"
Exit function
End if
GetHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")
Set Http=Nothing
If Err.number<>0 then
Err.Clear
End If
End Function

Function BytesToBstr(Body,Cset)
Dim Objstream
Set Objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function

Function GetBody(ConStr,StartStr,OverStr,IncluL,IncluR)
If ConStr="$False$" or ConStr="" or IsNull(ConStr)=True Or StartStr="" or IsNull(StartStr)=True Or OverStr="" or IsNull(OverStr)=True Then
GetBody="$False$"
Exit Function
End If
Dim ConStrTemp
Dim Start,Over
ConStrTemp=Lcase(ConStr)
StartStr=Lcase(StartStr)
OverStr=Lcase(OverStr)
Start = InStrB(1, ConStrTemp, StartStr, vbBinaryCompare)
If Start<=0 then
GetBody="$False$"
Exit Function
Else
If IncluL=False Then
Start=Start+LenB(StartStr)
End If
End If
Over=InStrB(Start,ConStrTemp,OverStr,vbBinaryCompare)
If Over<=0 Or Over<=Start then
GetBody="$False$"
Exit Function
Else
If IncluR=True Then
Over=Over+LenB(OverStr)
End If
End If
GetBody=MidB(ConStr,Start,Over-Start)
End Function
什么都不能 2006-10-12
  • 打赏
  • 举报
回复
这样可以
如果
你得到的内容为 body
即:response.write body 就可以得到你要的页面
那么
令 self="<script>window.name=""sname"";</script>"
body=self+body
最终得:
response.write body
yaya_sky 2006-10-12
  • 打赏
  • 举报
回复
你在一个名叫sname的窗口中执行这个文件试试
什么都不能 2006-10-11
  • 打赏
  • 举报
回复
那个网页的网址,顺便写一下你代码,看一下是否有问题

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧