[VBA ] 模擬IE,如何抓取有下拉式選單資料?

看板Visual_Basic作者 (Darren )時間2年前 (2021/12/07 15:26), 編輯推噓1(100)
留言1則, 1人參與, 3年前最新討論串1/1
1.使用軟體:Excel VBA 2.網址:https://goodinfo.tw/StockInfo/StockBzPerformance.asp?STOCK_ID=2108 3.想抓取的網頁資料:網頁裡的PER/PBR資料表格(如圖https://reurl.cc/52AG9V) 4.抓取資料到 資料表 B4 5.自己寫的程式碼,不知哪裡有錯? Sub 巨集1() ' ' ' Dim url As String Dim IE As Object Dim i, j As Integer Cells.Clear '第2步驟 建立IE Set IE = CreateObject("InternetExplorer.application") url = "https://goodinfo.tw/StockInfo/StockBzPerformance.asp?STOCK_ID=2108" With IE .Visible = True .navigate url Do While .Busy Or .ReadyState <> 4 Loop '第2步驟 底選下拉式選單 Set HtmlDoc = .document HtmlDoc.getElementByname("ChgFinDetailSheet(this.value);")(0).selectedindex = 3 '第3步驟 存入儲存個B4 i = 4 For Each nRow In Motable.Rows j = 2 For Each nCol In nRow.Cells Cells(i, j) = nCol.innertext j = j + 1 Next i = i + 1 Next .Quit End With ' End Sub -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 49.216.222.35 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Visual_Basic/M.1638862013.A.20E.html

04/13 12:17, 3年前 , 1F
getelement"s"byname可能少打s
04/13 12:17, 1F
文章代碼(AID): #1Xhmoz8E (Visual_Basic)
文章代碼(AID): #1Xhmoz8E (Visual_Basic)