返回列表 上一主題 發帖

[發問] 請教這網頁附圖表格是在第幾???(table)

本帖最後由 GBKEE 於 2020-5-10 15:20 編輯

回復 3# t8899

  1. Option Explicit
  2. Sub Ex()
  3.     Dim R As Integer, C As Integer
  4.     With New InternetExplorer  '**設定引用項目加入-->   Microsoft Internet Controls***
  5.        .Visible = True
  6.         .Navigate "https://pchome.megatime.com.tw/rank/sto0/ock03.html"
  7.         Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
  8.                      '<table style="margin-top: 10px;" cellspacing="1" cellpadding="0" **網頁的內容**
  9.          With .Document.querySelector("table[style='margin-top: 10px;'][cellspacing='1'][cellpadding='0']")
  10.          '' With .Document.all.tags("table")(0) '** 也可以
  11.             For R = 0 To .Rows.Length - 1
  12.                 For C = 0 To .Rows(R).Cells.Length - 1
  13.                     ActiveSheet.Cells(R + 1, C + 1) = .Rows(R).Cells(C).innerText
  14.                 Next
  15.             Next
  16.         End With
  17.          .Quit
  18.       End With
  19. End Sub
複製代碼
感恩的心......(在麻辣家族討論區.用心學習會有進步的)
但資源無限,後援有限,  一天1元的贊助,人人有能力.

TOP

        靜思自在 : 人生不一定球球是好球,但是有歷練的強打者,隨時都可以揮棒。
返回列表 上一主題