怎么用XML获取指定需要的数据

yesun 2005-01-24 08:06:56
例如获取http://t4211.bliao.com的页面
我已经得到数据后。怎么分析出 在线人数:(N人) 里面的数字N
怎么根据输入的一个参数而获取其他页呢? 例如我要获取t4212的
可否用一个ASP带一个参数显示指定序号的页面在线人数呢?

...全文
206 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
yesun 2005-01-28
  • 打赏
  • 举报
回复
好象没有显示啊
scoutlin 2005-01-27
  • 打赏
  • 举报
回复

response.write Match.submatches(0)
这行改成
online= Match.submatches(0)

-_-'
scoutlin 2005-01-27
  • 打赏
  • 举报
回复
js的我弄不来
下面是ASP实现的
<%
'调用方法,文件名.asp?id=xxxxx
id=request("id")
if id="" then id="t4212"
online=""
contents=getHTTPPage("http://"&id&".bliao.com")
Dim Regex
Set Regex = New Regexp
Regex.Pattern = "<td align=\""center\"">在线人数:<font color=\""#ff6600\"">\((\d+)人\)</font></td>"
Regex.Ignorecase = True
Regex.Global = True
Set Matches =Regex.Execute(contents)
For Each Match In Matches
response.write Match.submatches(0)
Next
Set Matches =Nothing
Set Regex=Nothing
response.write online

Function Bytes2Bstr2(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
Bytes2Bstr2 = objstream.ReadText
objstream.Close
set objstream = nothing
End Function

function getHTTPPage(url)
on error resume next
dim http
'set http=Server.createobject("Msxml2.XMLHTTP")
set http=Server.createobject("Microsoft.XMLHTTP")
Http.open "GET",url,false
Http.send()
if Http.readystate<>4 then exit function
getHTTPPage=bytes2BSTR2(Http.responseBody,"GB2312")
set http=nothing
if err.number<>0 then err.Clear
end function
%>
yesun 2005-01-27
  • 打赏
  • 举报
回复
UP
yesun 2005-01-24
  • 打赏
  • 举报
回复
大家帮忙给个例子吧
yesun 2005-01-24
  • 打赏
  • 举报
回复
非常感谢E章那么快解答我的问题
但我不懂得把得到的代码分析出来

例如获取到代码后。 怎么在那一堆代码中分析出 在线人数:(N人) 里面的N人
我获取这个页其实就只是要得到N 其余的都是没有用的

也就是怎么分析<td align="center">在线人数:<font color="#ff6600">(2人)</font></td></tr>这段得出N

还有 可能刚才表达有错误

例如这个XMLHTTP页的名字是 a.asp
那么只要输入a.asp?id=t4211 就是获取 "http://"+id+".bliao.com/"的代码行不?

最好能给个立刻能用的代码。没有的话举个例子。听说要用到正则,但正则我还没有掌握的。
孟子E章 2005-01-24
  • 打赏
  • 举报
回复
xxx = "t4212"
URL = "http://t4211.bliao.com/?id=" + xxx

xmlhttp.Open("GET",URL, false);

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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