Excel 请问如何用VBA提取这个网页上的开奖号码

2022-11-01 19:50发布

Subcc()Cells.ClearContentsSetoDoc=CreateObject(htmlfile)[a1:c1]=Array(时间,开奖

Subcc()Cells.ClearContentsSetoDoc=CreateObject("htmlfile")[a1:c1]=Array("时间","开奖
5条回答
2022-11-01 20:51

Sub cc()

    Cells.ClearContents

    Set oDoc = CreateObject("htmlfile")

    [a1:c1] = Array("时间", "开奖号码", "冠亚军和")

    [f1] = "1~5龙虎"

    [c1:e1].Merge: [f1:j1].Merge

    With CreateObject("MSXML2.XMLHTTP")

        .Open "GET", "http://www.1396me.com/pk10/kaijiang", True

        .Send

        Do Until .ReadyState = 4

            DoEvents

        Loop

        s = Replace(Replace(.responseText, """></i>", "</i>"), "pk-no", """>")

        oDoc.body.innerHTML = s

        Set r = oDoc.All.Tags("table")(0).Rows

        For i = 0 To r.Length - 1

            For j = 0 To r(i).Cells.Length - 1

                Cells(i + 1, j + 1) = r(i).Cells(j).innerText

            Next j

        Next i

        Set r = Nothing

    End With

End Sub
本回答被提问者和网友采纳