- 帖子
- 5923
- 主題
- 13
- 精華
- 1
- 積分
- 5986
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- Office 2010
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台灣基隆
- 註冊時間
- 2010-5-1
- 最後登錄
- 2022-1-23
        
|
12#
發表於 2014-6-23 09:42
| 只看該作者
本帖最後由 GBKEE 於 2014-6-23 09:43 編輯
回復 11# 小俠客 - '網頁搜尋結果: 0 記錄
- Option Explicit
- Sub IE下一頁()
- Dim url As String, a As Object, Table As Object, i As Integer, pubSrch As Object, Pages As Integer
- Dim Sh As Worksheet, B As String, E
- Set Sh = ActiveSheet
- Sh.Cells.Clear
- '************************************
- url = "https://eservices.customs.gov.hk/MSOS/wsrh/001s1?"
- 'url = "https://eservices.customs.gov.hk/MSOS/wsrh/001s1?"searchBy=A" '網頁有資料
- '************************************
- With CreateObject("InternetExplorer.Application")
- .Visible = True ' 是否顯示 IE
- .Navigate url
- Do While .ReadyState <> 4 Or .Busy
- DoEvents
- Loop
- Do
- Set a = .Document.getElementsByTAGName("TD")
- Loop Until Not a Is Nothing 'And a.Length = 84
- On Error Resume Next
- With Sh
- For i = 0 To a.Length - 1
- .Cells(i + 1, "A") = i
- .Cells(i + 1, "B") = a(i).Type
- .Cells(i + 1, "C") = a(i).ID
- .Cells(i + 1, "D") = a(i).InnerText
- .Cells(i + 1, "E") = a(i).Value
- Next
-
- End With
-
- .Quit
- End With
- MsgBox "getElementsByTAGName(""TD"") 合計 " & a.Length
- End Sub
複製代碼
|
|