暱稱: joey0415
中學生
- 帖子
- 361
- 主題
- 57
- 精華
- 0
- 積分
- 426
- 點名
- 0
- 作業系統
- win7
- 軟體版本
- 2003,2010
- 閱讀權限
- 20
- 性別
- 男
- 註冊時間
- 2010-5-13
- 最後登錄
- 2022-12-8
|
回復 5# c_c_lai
賴大試試,我只會拿以前的來改
- Sub 證交所()
-
- Dim strText As String
- Dim i As Integer
- Dim j As Integer
- Dim nRow As Integer
- Dim xRow As Integer
- Dim nCol As Byte
- Dim TR As Object
- Dim TD As Object
- Dim Arr()
- Cells.Clear
-
- With CreateObject("winhttp.winhttprequest.5.1")
- .Open "POST", "http://www.twse.com.tw/ch/trading/exchange/TWTB4U/TWTB4U.php", False
- .setrequestheader "Referer", "http://www.twse.com.tw/ch/trading/exchange/TWTB4U/TWTB4U.php"
- .setrequestheader "Content-Type", "application/x-www-form-urlencoded"
- .Send "input_date=105%2F06%2F15&select2=21&login_btn=+%ACd%B8%DF+"
- strText = BinToStr(.ResponseBody, "BIG5") '要注意網頁編碼
- End With
-
- With CreateObject("htmlfile")
- .Write strText
- Set hTable = .all.tags("table")(8)
- tt = hTable.Rows.Length
- With ActiveSheet
- For i = 0 To hTable.Rows.Length - 1
- For j = 0 To hTable.Rows(i).Cells.Length - 1
- .Cells(i + 1, j + 1) = hTable.Rows(i).Cells(j).innertext
- Next
- Next
- End With
-
- End With
- End Sub
- Function BinToStr(arrBin, strChrs)
- With CreateObject("ADODB.Stream")
- .Type = 2
- .Open
- .Writetext arrBin
- .Position = 0
- .Charset = strChrs
- .Position = 2
- BinToStr = .ReadText
- .Close
- End With
- End Function
複製代碼 |
|