|
- Sub 你把网页的那些input都贴到表格上不觉得很卡的吗()
- Dim HTML, TD, result, TABLE, TB_TR, TB_TD, TB_TRS, TB_TDS, dwRow, dwCol
- Dim dwSumRow, dwSumCol
- a = [{"平均值","最高值","最低值","离散值"}]
- On Error Resume Next
- arr = Sheets("欧赔地址").Range("e1:e14")
- Set http = CreateObject("Msxml2.XMLHTTP")
- Set HTML = CreateObject("HTMLFILE")
- ReDim result(1 To Cells.Rows.Count, 1 To 20)
- For Each szUrl In arr
- http.Open "GET", szUrl, False
- http.send
- If http.readyState = 4 Then
- szHttpText = StrConv(http.responseBody, vbUnicode)
- szHttpText = Mid(szHttpText, InStr(szHttpText, "id=""table_btm"""))
- szHttpText = "<div " & Left(szHttpText, InStr(szHttpText, "<div class=""odds_msg2""") - 2)
- HTML.write szHttpText
- For Each TR In HTML.getElementsByTagName("tr")
- If TR.getAttribute("xls") Then
- k = k + 1 '引数
- For Each TABLE In TR.getElementsByTagName("table")
- If TABLE.className = "pl_table_data" Then
-
- '表格内容
- Set TB_TRS = TABLE.getElementsByTagName("tr") '行集合
- For dwRow = 0 To TB_TRS.Length - 1
- Set TB_TDS = TB_TRS(dwRow).getElementsByTagName("td") '列集合
- For dwCol = 0 To TB_TDS.Length - 1 '行
- If TB_TDS(dwCol).innerText <> "" Then
- result(dwRow + dwSumRow + 1, dwCol + dwSumCol + 2) = TB_TDS(dwCol).innerText '存放结果内容
- End If
- Next
- Next
-
- dwSumCol = dwSumCol + dwCol
-
- End If
- Next
- '归位
-
- dwSumCol = 0
- dwSumRow = dwSumRow + 2
- result(dwSumRow - 1, 1) = a(k)
- End If
- Next
- k = 0
- HTML.Close
- End If
- dwSumRow = dwSumRow + 1
- Next
- [A1].Resize(dwSumRow, 20) = result
- End Sub
复制代码 |
|