返回列表 上一主題 發帖

如何找出下載CSV檔的參數

如何找出下載CSV檔的參數

請高手指點上市買賣日報表查詢系統http://bsr.twse.com.tw/bshtm/
如何找出下載CSV檔的參數

回復 1# chihminyang88
參數是沒有用的,重點是圖形認證

TOP

回復 2# joey0415

感謝提醒,因有用  " 請問如何將網頁的圖片存檔 " 搜尋到本網站G大的VB範例
所以圖片碼問題已解決,但沒找到上市下載CVS檔的參數, 大大您若知悉可否指
點一下,感恩 !

TOP

回復 3# chihminyang88

所以你要手動一檔一檔key下載

TOP

回復 3# chihminyang88

範例試試看


    Ex.rar (23.17 KB)
感恩的心......(在麻辣家族討論區.用心學習會有進步的)
但資源無限,後援有限,  一天1元的贊助,人人有能力.

TOP

回復 4# joey0415
因研究VB時間不久,所以先求有再想辦法求好,大大可有想法或建議提供 ,謝謝!

TOP

回復 5# GBKEE
謝謝G大提供的程式,先收下 慢慢研究程式碼中,感謝!

TOP

回復 7# chihminyang88

點數不足.請問可以開放程式嗎..謝謝

TOP

回復 8# abba9817
不了解可參考這裡



上市工作表模組的程式碼
  1. Public ie As Object, Msg As Boolean
  2. Const 圖形 = "d:\驗證圖.jpg"
  3. Const 證券代號 = "F2"
  4. Const 驗證碼 = "F4"
  5. Private Sub Worksheet_Change(ByVal Target As Range)
  6.     Range(證券代號).Interior.ColorIndex = IIf(Range(證券代號).Value = "", 2, 36)
  7.     With Target.Cells(1)
  8.          If .Address(0, 0) = 驗證碼 Then .Interior.ColorIndex = IIf(Len(Trim(.Cells)) = 5, 36, 2)
  9.          If .Address(0, 0) = 驗證碼 And Len(Trim(.Cells)) = 5 And Range(證券代號).Value <> "" Then
  10.             If ie Is Nothing Then
  11.                 Target = ""
  12.                 Msg = True
  13.                 圖形更新
  14.                 Exit Sub
  15.             End If
  16.             Application.EnableEvents = False
  17.             讀取日報表網頁
  18.             Target = ""
  19.             Me.Activate
  20.             Application.EnableEvents = True
  21.         End If
  22.     End With
  23. End Sub
  24. Private Sub 讀取日報表網頁()
  25.     Dim S As String
  26.     Application.EnableEvents = True
  27.     If ie Is Nothing Then
  28.         圖形更新
  29.         MsgBox "驗證圖已更新"
  30.         Exit Sub
  31.     End If
  32.     With ie
  33.         .navigate "http://bsr.twse.com.tw/bshtm/bsMenu.aspx"
  34.         Do While .Busy Or .readyState <> 4: DoEvents: Loop
  35.         .Document.All("TextBox_Stkno").Value = Range(證券代號)
  36.         .Document.All("CaptchaControl1").Value = Range(驗證碼)
  37.         .Document.All("btnOK").Click
  38.         Do While .Busy Or .readyState <> 4: DoEvents: Loop
  39.         If InStr(.Document.body.Innertext, "查無資料") Then
  40.         S = Range(證券代號) & " 查無資料"
  41.         ElseIf InStr(.Document.body.Innertext, "驗證碼錯誤!") Then
  42.             S = "驗證碼錯誤!"
  43.         Else
  44.             日報表下載
  45.             日報表_整理_存檔
  46.             S = "下載 " & Range(證券代號) & " CSV OK"
  47.             With Cells(Rows.Count, 1).End(xlUp)
  48.                 If .Row < 6 Then
  49.                     Range("A6") = S
  50.                 Else
  51.                     .Cells(2) = S
  52.                 End If
  53.             End With
  54.         End If
  55.         [A1] = S
  56.     End With
  57.     圖形更新
  58. End Sub
  59. Private Sub 日報表下載()
  60.       With CreateObject("InternetExplorer.Application")
  61.         .Visible = True
  62.         .navigate "http://bsr.twse.com.tw/bshtm/bsContent.aspx?v=t"
  63.         Do While .Busy Or .readyState <> 4: DoEvents: Loop
  64.         .ExecWB 17, 2
  65.         .ExecWB 12, 2
  66.          .Quit
  67.       End With
  68. End Sub
  69. Private Sub 日報表_整理_存檔()
  70.     Dim Rng As Range, E As Range
  71.     With Sheet2
  72.         .Activate
  73.         .UsedRange.Clear
  74.         .Range("A1").Select
  75.         .PasteSpecial Format:="HTML", Link:=False, DisplayAsIcon:=False, NoHTMLFormatting:=True
  76.         .UsedRange.Offset(10).Columns(1).Replace "交易日期", "=aaa", xlWhole
  77.         With .UsedRange
  78.             For Each E In .SpecialCells(xlCellTypeFormulas, xlErrors).Areas
  79.                 If Rng Is Nothing Then
  80.                     Set Rng = E.Offset(-1).Resize(5, 16)
  81.                 Else
  82.                     Set Rng = Union(Rng, E.Offset(-1).Resize(5, 16))
  83.                 End If
  84.             Next
  85.              .SpecialCells(xlCellTypeBlanks).Delete xlShiftToLeft
  86.         End With
  87.         Rng.Delete
  88.         .Copy          '工作複製
  89.     End With
  90.     Application.DisplayAlerts = False
  91.     With ActiveWorkbook
  92.         .Sheets(1).Name = Range(證券代號)
  93.         '*******"D:\TEST\" 可修改 ************************
  94.         .SaveAs "D:\TEST\" & Range(證券代號).Text & ".CSV"
  95.         '*************************************************
  96.         .Close True
  97.     End With
  98.     Application.DisplayAlerts = True
  99. End Sub
  100. Private Sub 圖形更新()
  101.     Shell "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8"  'Clear_IE_Temp_Files
  102.     If Not ie Is Nothing Then ie.Quit:  Set ie = Nothing
  103.     Set ie = CreateObject("InternetExplorer.Application")
  104.     If Msg Then MsgBox "驗證圖 更新完畢"
  105.     Msg = False
  106.     With ie
  107.         .navigate "http://bsr.twse.com.tw/bshtm/bsMenu.aspx"
  108.         .Visible = True
  109.         Do While .Busy Or .readyState <> 4: DoEvents: Loop
  110.         網路圖片存檔 .Document.All.TAGS("IMG")(1).href
  111.     End With
  112.     Sheet1.Shapes("驗證圖").Fill.UserPicture 圖形
  113. End Sub
  114. Private Sub 網路圖片存檔(img As String)
  115.     Dim xml As Object     '用來取得網頁資料
  116.     Dim stream            'As ADODB.stream   '用來儲存二進位檔案
  117.     Set xml = CreateObject("Microsoft.XMLHTTP")
  118.     Set stream = CreateObject("ADODB.stream")
  119.     xml.Open "GET", img, 0
  120.     xml.send
  121.     With stream
  122.         .Open
  123.         .Type = 1
  124.         .write xml.responseBody
  125.         If Dir(圖形) <> "" Then Kill 圖形
  126.         .SaveToFile (圖形)
  127.         .Close
  128.     End With
  129. End Sub
複製代碼
感恩的心......(在麻辣家族討論區.用心學習會有進步的)
但資源無限,後援有限,  一天1元的贊助,人人有能力.

TOP

回復 9# GBKEE

太感謝了.....

TOP

        靜思自在 : 成功是優點的發揮,失敗是缺點的累積。
返回列表 上一主題