- ©«¤l
- 361
- ¥DÃD
- 57
- ºëµØ
- 0
- ¿n¤À
- 426
- ÂI¦W
- 0
- §@·~¨t²Î
- win7
- ³nÅ骩¥»
- 2003,2010
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2010-5-13
- ³Ì«áµn¿ý
- 2022-12-8
|
½Ð±Ð¤@¤U¦U¦ìVBA°ª¤â¡A§Q¥ÎVBAµ{¦¡¶}±Òºô¶¾Þ§@³oÓ§Ú·|
ºô¶¤]³]©wVisible=False¤F¡A¦ý¦P¼Ëµ{¦¡½X¦b¤£¦P¹q ...
smart3135 µoªí©ó 2020-1-21 23:35 - Sub test()
- ¦~ = 2019
- ªÑ²¼¥N½X = 1259
- Cells.Clear
- Dim oXML As Object
- Set oXML = CreateObject("WinHttp.WinHttpRequest.5.1")
- Dim oHTML As Object
- Set oHTML = CreateObject("HTMLFile")
- With oXML
- .Open "POST", "https://www.tpex.org.tw/web/stock/statistics/monthly/result_st44.php?l=zh-tw", 0
- .setRequestHeader "Content-Type", "application/x-www-form-urlencoded;"
- .setRequestHeader "Origin", "https://www.tpex.org.tw"
- ' .send "ajax=true&l=zh-tw&yy=2020&input_stock_code=1258"
- .send "ajax=true&l=zh-tw&yy=" & ¦~ & "&input_stock_code=" & ªÑ²¼¥N½X
- oHTML.body.innerHTML = convertraw(.responseBody, "UTF-8")
- Debug.Print oHTML.body.innerHTML
- End With
- Dim oTable As Object, oRow As Object, oCell As Object
- Dim i As Integer, j As Integer
- Set oTable = oHTML.getElementsByTagName("table")(2)
- i = 1
- For Each oRow In oTable.Rows
- j = 1
- For Each oCell In oRow.Cells
- Cells(i, j).Value = oCell.innerText
- j = j + 1
- Next oCell
- i = i + 1
- Next oRow
- Set oHTML = Nothing
- Set oXML = Nothing
- End Sub
- Function convertraw(rawdata, char)
- Dim rawstr
- Set rawstr = CreateObject("adodb.stream")
- With rawstr
- .Type = 1
- .Mode = 3
- .Open
- .Write rawdata
- .Position = 0
- .Type = 2
- .Charset = char
- convertraw = .ReadText
- .Close
- End With
- Set rawstr = Nothing
- End Function
½Æ»s¥N½X |
|