asp中,用vbscript中的GetSourceCode方法去获取一个返回值

jesseqj 2008-04-15 03:17:22
本人现在想用asp vbscript脚本做一个程序
主要功能是:
用GetSourceCode方法向某一网站发出请求,并取回请求的数据!例如GetSourceCode方法里面是一个指向上海天气预报的网页,现在要显示从那个天气预报网站取回来的值,各位大侠帮帮忙啊,急......最好能给个例子
...全文
124 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
'dom.selectSingleNode(...)'那就是里面的信息密友获取到,一般旧似乎这几种情况
jesseqj 2008-04-15
  • 打赏
  • 举报
回复
汗,我定义了,不知道怎么搞的
Dim dom
Set dom = Server.CreateObject("MSXML2.DOMDocument")
dom.load(request)
m_text = dom.selectSingleNode("//Text").text

dim keywordNodes
Set keywordNodes = dom.selectNodes("//Word")
  • 打赏
  • 举报
回复
就是你的对象没有定义,或者不存在!
jesseqj 2008-04-15
  • 打赏
  • 举报
回复
不会吧,那你告诉我“缺少对象: 'dom.selectSingleNode(...)'”是什么意思吗?
  • 打赏
  • 举报
回复
删除了!
jesseqj 2008-04-15
  • 打赏
  • 举报
回复
找到了没有?帮帮忙啊.....
顺便问下“缺少对象: 'dom.selectSingleNode(...)'”是什么意思?
jesseqj 2008-04-15
  • 打赏
  • 举报
回复
我是刚学,这个有点复杂,看不明白
  • 打赏
  • 举报
回复
呵呵,以前还做了一个天气预报的例子,不记得放哪了,我找找看
  • 打赏
  • 举报
回复
给你看一个XMLHTTP的例子:

response.Charset="gb2312" 

Sub newsSina
dim Content,url,ShowContent
url="http://news.sina.com.cn/news1000/index.shtml"

Content=GetNewsContent(url)
response.write Content
'Content="<a href='www.a.com'>a </a><a href='www.bb.com'>bb </a><a href='www.ccc.com'>ccc </a> "
set re=new RegExp
're.pattern="\[.*?\)"
re.pattern="<li>.*"
re.Global=true
re.IgnoreCase=true
set matches=re.execute(Content)
For Each Match in matches
'ShowContent=ShowContent&right(match.Value,len(match.value)-4)&"<br>"
ShowContent=ShowContent&ChangeURL(right(match.Value,len(match.value)-4))&"<br>"
'response.write ChangeURL(right(match.Value,len(match.value)-4))&"<br>"
next
'ShowContent=ShowContent&"<br><a href=# onclick=vbscript:history.back>返回首页</a>"
'response.write "<font size=2>"&ShowContent&"</font>"


End Sub

Function ChangeURL(str)
'response.write str&"<br>"

set Rep=new regExp
Rep.pattern="http.*\b"
Rep.Global=true
Rep.IgnoreCase=true
set RepMatches=Rep.execute(str)
'Rtn=Rep.test(str)
'response.write Rtn
For Each RepMatch in Repmatches
ChangeURL=replace(str,RepMatch.value,RepMatch.value)
'response.write RepMatch.value&"<br>"
next

End Function

Function GetNewsContent(URL)
set objHttp=server.createobject("Microsoft.XMLHttp")
'objHttp.open "get","http://news.sina.com.cn/news1000/index.shtml";,false
objHttp.open "get",URL,false
objHttp.send()

if objHttp.readystate<>4 then
exit function
end if

GetNewsContent=bytes2BSTR(objHttp.responseBody)

'GetNewsContent=objHttp.responseText
'GetNewsContent=B2B(objHttp.responsebody)
End Function


Function bytes2BSTR(vIn)
dim strReturn
dim i1,ThisCharCode,NextCharCode
strReturn = ""
For i1 = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i1,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i1+1,1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
i1 = i1 + 1
End If
Next
bytes2BSTR = strReturn
End Function



Call newsSina
jesseqj 2008-04-15
  • 打赏
  • 举报
回复
chinmo这个大哥,能给个例子吗
或者能说详细点吗
jesseqj 2008-04-15
  • 打赏
  • 举报
回复
那个从网页取回来的值,就是该网页所提供的服务,它能回馈给我当天的天气情况。
  • 打赏
  • 举报
回复
呵呵,这个我以前弄过!!
利用XMLHTTP

28,391

社区成员

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

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