|
fjtc.com.cn/Line-1105
上面是网址,要提取其中红圈里的信息如图。可行吗
- Sub 查询福彩前4页()
- Dim strDate$
- Dim strUrl$
- Dim strText$
- Dim strFind$
- Dim arr1, arr2, result(1 To 400, 1 To 6)
- Dim i As Long, j As Byte, k As Byte, m As Integer
- Dim httpRequest As Object
- Dim btPage As Byte
- m = 1
- '标题
- result(m, 1) = "期数"
- result(m, 2) = "开奖号码"
- For btPage = 1 To 4
- strUrl = "http://fjtc.com.cn/Line-1105?Page=" & btPage
- Set httpRequest = CreateObject("Msxml2.XMLHTTP.3.0")
- With httpRequest
- .Open "GET", strUrl, False
- .send
- strText = .responseText
- End With
- strFind = "<table class=""cpzs_table mt10"">"
- strText = Split(strText, strFind)(1)
- strText = Split(strText, "</table>")(0)
- arr1 = Split(strText, "</tr>")
- For j = 4 To UBound(arr1)
- If arr1(j) Like "<tr><td>*" Then
- arr2 = Split(arr1(j), "</td>")
- m = m + 1
- '第1列期数
- result(m, 1) = Split(Split(arr1(j), "</td")(0), "<td>")(1)
- '第2列到6列
- For k = LBound(arr2) + 1 To UBound(result, 2) - 1
- result(m, k + 1) = Split(Split(arr2(k), "<span class=""spNum"">")(1), "<")(0)
- Next
- Else
- Exit For
- End If
- Next
- Next
- Application.ScreenUpdating = False
- With Range("a1")
- .CurrentRegion.ClearContents
- .Resize(m, UBound(result, 2)).Value = result
- .CurrentRegion.EntireColumn.AutoFit
- End With
- Range("B1:F1").HorizontalAlignment = xlCenterAcrossSelection
- Application.ScreenUpdating = True
- MsgBox "提取完成"
- End Sub
复制代码
|
|