求教如何用ASP取此网页上的数据。

powerc1 2018-05-12 08:16:50
数据页:http://service.99qh.com/hold2/MemberGoodsHold/GetTableHtml.aspx?date=2018-04-24&mem=17&user=99qh&script=no

请教如何用ASP取网页中的:“品种”,“多头持仓”,“空头持仓”,“净头寸” 的数据。谢谢。
...全文
880 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
Go 旅城通票 2018-05-12
  • 打赏
  • 举报
回复
正则获提取下就行了。。。
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
  private function BinToString(bin,encoding)
    dim obj
    set obj=Server.CreateObject("Adodb.Stream")
    obj.Type=1:obj.Mode=3:obj.Open
    obj.Write bin
    obj.Position=0:obj.Type=2:obj.Charset=encoding
    BinToString=obj.ReadText
    obj.Close:set obj=nothing
  end function
  
    Set oHttp = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
    ohttp.open "get","http://service.99qh.com/hold2/MemberGoodsHold/GetTableHtml.aspx?date=2018-04-24&mem=17&user=99qh&script=no",false
    ohttp.send(null)
    Set oHttp=nothing
 
 
    html=BinToString(ohttp.ResponseBody,"utf-8")
   
Response.CharSet="utf-8"

set re=new RegExp
re.Global=true
re.IgnoreCase=true
re.Pattern="</?a[^>]*>"
html=re.Replace(html,"")'先去掉链接
re.Pattern="<tr><td[^>]*>([^<]+)</td><td[^>]*>([^<]+)</td><td[^>]*>([^<]+)</td><td[^>]*>([^<]+)</td>"
set mc=re.Execute(html)
    Response.Write mc.count
for each m in mc
  response.Write "品种:"&m.submatches(0)&"<br>多头持仓:"&m.submatches(1)&"<br>空头持仓:"&m.submatches(2)&"<br>净头寸:"&m.submatches(3)&"<br><hr>"
next
set re=nothing
%>


Web开发学习资料推荐
asp json类库解析json字符串
jqGrid单元格编辑配置,事件及方法

28,390

社区成员

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

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