日期:2014-05-16  浏览次数:20812 次

asp如何跨域读取数据并存入自己的数据库?
例如我要将
http://www.gxcaipiao.com.cn/klsfnt.jsp
这个网页的开奖号码数据取得存入ASP变量,然后更新到我的ACCESS数据库中,请问怎么做?

------解决方案--------------------

<%
url = "http://www.gxcaipiao.com.cn/noticequery_noticeQuery.action?period=2013116&lotterycode=12"
Set oDoc    = CreateObject("Msxml2.DOMDocument")
With oDoc
    .async              = False
    .validateOnParse    = False
    .preserveWhiteSpace = False
    .resolveExternals   = False
    .load url
    If .parseError.errorCode <> 0 Then
        sErrMsg     = .parseError.errorCode & "
------解决方案--------------------
" &_
                      .parseError.srcText & "
------解决方案--------------------
" & .parseError.reason
        Set oDoc = Nothing
        Response.Write sErrMsg
        Response.End
    End If
End With
Set oRoot = oDoc.documentElement
If oRoot.getAttribute("errcode")<>"0000" Then
        Response.Write sErrMsg
        Response.End
End If
Set oLot = oRoot.selectSingleNode("lottery")
perdid = oLot.getAttribute("perdid")
lottname = oLot.getAttribute("lottname")
awardcode = oLot.getAttribute("awardcode")
awarddate = oLot.getAttribute("awarddate")
s  = "名称:" & lottname & " " &_
     "期数:" & perdid & " " &_
     "开奖号码:" & awardcode & " " &_
     "开奖日期:" & awarddate & "<br>"
Set oNodes = oLot.selectNodes("//level")
For i = 0 To oNodes.length-1
    s = s & oNodes(i).getAttribute("name") & " " &_
        oNodes(i).getAttribute("localcount") & " " &_
        oNodes(i).getAttribute("money") & "<br>"
Next
Set oNodes = oLot.selectSingleNode("//pool[@index=1]")
s = s & "销售金额:" & oLot.getAttribute("localsale") & " " &_
    "中奖金额:" & oLot.getAttribute("localaward") & " "