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