ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

ªÑ²¼¸ê®Æ¶×¤J¡Aµ{¦¡°õ¦æ¦³°ÝÃD

¥»©«³Ì«á¥Ñ GBKEE ©ó 2016-6-12 15:02 ½s¿è

¦^´_ 16# c_c_lai


   
url ¸Ì¬°¦ó§Ú¤@ª½§ì¤£¨ì¥¿½Tªº selectType ¹ïÀ³­È¡H
  ºô­¶ªº«Ø¸m§Ú¨S¤Jªù,©Ò¥H§Ú¤]¦bºN¯Á¤¤


  .getElementsByName:      getElements ½Æ¼Æ-> ª«¥óªº¶°¦X
  .getElementsBytagName:  getElements ½Æ¼Æ-> ª«¥óªº¶°¦X
  .ALL.tags:                     tags ½Æ¼Æ-> ª«¥óªº¶°¦X
  .getElementById :          getElement  ³æ¼Æ ->³æ¤@ªºª«¥ó
  1. Set xTable = oHtmldoc.ALL.tags("TABLE")
  2. Stop
  3. '¬Ý¬Ý°Ï°ìÅܼƵøµ¡ xTable ªº¤º®e
  4.     Set xTable = oHtmldoc.ALL.tags("TABLE")(0)
  5. Stop
  6. '¦A¦¸¬Ý¬Ý°Ï°ìÅܼƵøµ¡ xTable ªº¤º®e
  7.     MsgBox xTable.INNERTEXT
½Æ»s¥N½X
ªþÀɤ¤¦³³\¦h¬Û¦Pªºµ{¦¡½X.,,,,,,,,,,,
  1.      TVal = Array("MS", "", "0049", "0099P", "019919T", "0999", "0999P", "01", "02", "03", _
  2.                 "04", "05", "06", "07", "21", "22", "08", "09", "10", _
  3.                 "11", "12", "13", "24", "25", "26", "27", "28", "29", _
  4.                 "30", "31", "14", "15", "16", "17", "18", "23", "9299", "19", "20", "CB")
  5.     '**************************
  6.    If .ComboBox1.Value = "Select Name" Then
  7.             MsgBox ("±z©|¥¼¿ï¾Ü¡u²£·~Ãþ§O¡v¡A½Ð©ó" & vbCrLf & "½T»{«á¦A¦¸ÂI¿ï¡y¶}±Òºô­¶¡z¡A" & vbCrLf & "ÁÂÁ±z¡I")
  8.             Exit Sub
  9.         End If        
  10.         For cts = 0 To UBound(lst)
  11.             If lst(cts) = .[D1] Then select2 = TVal(cts): Exit For
  12.         Next cts
½Æ»s¥N½X
¥i¥H¾ã¦X¤@¤U
  1. Option Explicit
  2. Const MyUrl = "http://www.twse.com.tw/ch/trading/exchange/MI_MARGN/MI_MARGN.php"
  3. Private Sub Workbook_Open()
  4.     Dim oHtmldoc, op, cts
  5.     Set oHtmldoc = CreateObject("htmlfile")
  6.     With CreateObject("msxml2.xmlhttp")
  7.         .Open "Get", MyUrl, False
  8.         .Send
  9.         Do While .Status <> 200 Or .readyState <> 4: DoEvents: Loop
  10.         oHtmldoc.write .responseText
  11.     End With
  12.     Set op = oHtmldoc.all.tags("select")("selectType")
  13.     With Sheets("Á`ªí").ComboBox1
  14.         .Clear
  15.         For cts = 0 To op.Length - 1
  16.                 .AddItem                                             '²M³æ¤è¶ô©Î¤U©Ô¦¡²M³æ¤è¶ô¤¤¥[¤J¤@­Ó¶µ¥Ø
  17.                 .List(.ListCount - 1, 0) = op(cts).Text   ' ²Ä1Äæ,³Ì¦h9Äæ
  18.                 .List(.ListCount - 1, 1) = op(cts).Value ' ²Ä2Äæ,³Ì¦h9Äæ
  19.         Next
  20.         .Value = "Select Name"  '.List(0)  '0: «H¥Î¥æ©ö²Î­p, 1:¥þ³¡,2: «Ê³¬¦¡°òª÷......
  21.     End With
  22. End Sub
½Æ»s¥N½X
  1. Private Function Select_Name() As Integer
  2.     With Sheets("Á`ªí").ComboBox1
  3.         If .ListIndex = -1 Then MsgBox ("±z©|¥¼¿ï¾Ü¡u²£·~Ãþ§O¡v¡A½Ð©ó" & vbCrLf & "½T»{«á¦A¦¸ÂI¿ï¡y¶}±Òºô­¶¡z¡A" & vbCrLf & "ÁÂÁ±z¡I")
  4.         Select_Name = .ListIndex
  5.     End With
  6. End Function
½Æ»s¥N½X
  1. Sub ¿Ä¸ê¿Ä¨é2()
  2.     Dim qdate As String, select2 As String
  3.     'Dim TVal(), cts As Integer
  4.     If Select_Name = -1 Then
  5.         Exit Sub
  6.      Else
  7.         With Sheets("Á`ªí")
  8.             qdate = Format(.[B1], "EE/MM/DD")
  9.             With .ComboBox1
  10.             select2 = .List(.ListIndex, 1)
  11.             End With
  12.         End With
  13.      End If   
  14.     With Sheets("¿Ä¸ê_¿Ä¨é")
  15.         .Select
  16.         .Cells.Clear
  17.     End With
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 14# GBKEE
ÃB¥~¦A½Ð±Ð±z¡A¦bªþ¤W¤§¡y¿Ä¸ê¿Ä¨é»P¤W¥«·í¨R.xls¡z
¿ï¯Ã¡y¿Ä¸ê¿Ä¨é  III¡z¹ïÀ³ªº¡uSub ¿Ä¸ê¿Ä¨é3()¡v¡A
url ¸Ì¬°¦ó§Ú¤@ª½§ì¤£¨ì¥¿½Tªº selectType ¹ïÀ³­È¡H
¦b¡uSub ¿Ä¸ê¿Ä¨é2()¡v¨Ï¥Î .QueryTables.Add() ªº¤è¦¡
§Y¥i¥¿½T¨ú±o¡H
ÁÂÁ±z¡I
¿Ä¸ê¿Ä¨é»P¤W¥«·í¨R.rar (109.56 KB)
TWSE »OÆWÃÒ¨é¥æ©ö©Ò.rar (5.29 KB)

TOP

¦^´_  c_c_lai
³oºô­¶¦³¬y¶qºÞ¨î.
GBKEE µoªí©ó 2016-6-11 07:05

¨S¿ù¡A¥¦ÁÙ·|¥á¥X°T®§¡G
  1. ºô¯¸°»´ú¨ì±zªºÂsÄý¶q²§±`, ¥Ø«e¼È®ÉÃö³¬ªA°È, ½Ðµy«á¦A­«·s¬d¸ß
½Æ»s¥N½X
ÁÂÁ±zÅo¡I

TOP

¦^´_ 13# c_c_lai
³oºô­¶¦³¬y¶qºÞ¨î.
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 11# GBKEE
ªþ¤WÀɮ׳ö¨Ñ´ú¸Õ¡G
¾ú¥vªÑ»ù§ó·s.rar (27.88 KB)

TOP

¦^´_ 11# GBKEE
©ú¤Ñ§Ú¦A¨Ó¥J²Ó´ú¸Õ¤@¤U¡C
¤£«H¨¸¡Aµ²ªG¨ÌµM¦³¿ù»~«H®§¡G

TOP

¦^´_ 10# c_c_lai
XP IE8 ¥Î 6#ªºµ{¦¡½X,¨S¥[¤W¨¾¿ùªºµ{¦¡½X
¨S¦³§A©Ò»¡ªº¿ù»~
  1. http://goodinfo.tw/StockInfo/StockBzPerformance.asp?STOCK_ID=1437 &YEAR_PERIOD=10&RPT_CAT=M_YEAR
  2. 24       1437
  3. http://goodinfo.tw/StockInfo/StockBzPerformance.asp?STOCK_ID=1438 &YEAR_PERIOD=10&RPT_CAT=M_YEAR
  4. 24       1438
  5. http://goodinfo.tw/StockInfo/StockBzPerformance.asp?STOCK_ID=1439 &YEAR_PERIOD=10&RPT_CAT=M_YEAR
  6. 24       1439
  7. http://goodinfo.tw/StockInfo/StockBzPerformance.asp?STOCK_ID=1440 &YEAR_PERIOD=10&RPT_CAT=M_YEAR
  8. 24       1440
  9. http://goodinfo.tw/StockInfo/StockBzPerformance.asp?STOCK_ID=1441 &YEAR_PERIOD=10&RPT_CAT=M_YEAR
  10. 24       1441
  11. http://goodinfo.tw/StockInfo/StockBzPerformance.asp?STOCK_ID=1442 &YEAR_PERIOD=10&RPT_CAT=M_YEAR
  12. 24       1442
  13. http://goodinfo.tw/StockInfo/StockBzPerformance.asp?STOCK_ID=1443 &YEAR_PERIOD=10&RPT_CAT=M_YEAR
  14. 24       1443
  15. http://goodinfo.tw/StockInfo/StockBzPerformance.asp?STOCK_ID=1444 &YEAR_PERIOD=10&RPT_CAT=M_YEAR
  16. 24       1444
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_  c_c_lai
¥i¥[¤W¨¾¿ù
GBKEE µoªí©ó 2016-6-10 10:27

¦pªG xTable.Length ¬°¹s¡A
Until xTable.Length >= 19 ·|¦p¦P¦º­J¦P
¥Ã»·¥X¤£¨Ó¡A©Ò¥H§Ú§ï¦¨
If xTable.Length >= 19 Then
     .
    .
End If
¤´µM¬O¤@±À
  1. 1             0             1437
  2. 2             0             1438
  3. 3             0             1439
  4. 4             0             1440
  5. 5             0             1441
½Æ»s¥N½X

TOP

¦^´_ 8# c_c_lai
¥i¥[¤W¨¾¿ù
  1. Do
  2.             Set xTable = oHtmldoc.all.tags("TABLE")
  3.             Debug.Print xTable.Length, sn
  4.           ' If xTable.Length >= 19 Then Stop
  5.         Loop Until xTable.Length >= 19
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 6# GBKEE
½Ð±Ð±z¡A¦³¦n¦h¦^°õ¦æ¨ì
  1.         Set xTable = oHtmldoc.all.tags("TABLE")
  2.         With Sheets("Àç¹BÁZ®Ä")
  3.             '  .Cells.Clear
  4.             For Each E In Array(11, 13, 19) '11,13,19  "TABLE"
  5.                 k = k + 1
  6.                 For R = 0 To xTable(E).Rows.Length - 1
½Æ»s¥N½X
¤¤ªº   xTable(E).Rows.Length¡A «K²£¥Í¦p¤U¤§¿ù»~°T®§¡G
  1. °õ¦æ¶¥¬q¿ù»~ '91'
  2. ¨S¦³³]©wª«¥óÅܼƩΠWith °Ï°ìÅܼÆ
½Æ»s¥N½X
¬d¬Ý oXmlhttp.responseText : "<!DOCTYPE HTML>
<html lang="zh-TW">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <meta http-equiv="X-UA-Compatible" content="I
¤S¬Ý¤£¥X¦³¥ô¦óª¬ªp¡A ¦³®É xTable.length = 0 ©Î  xTable.length =  1 µ¥¡C

TOP

        ÀR«ä¦Û¦b : ¡i¥Í©R¦b©I§l¶¡¡j¦òªû»¡¡G¡u¥Í©R¦b©I§l¶¡¡C¡v¤HµLªkºÞ¦í¦Û¤vªº¥Í©R¡A§óµLªk¾×¦í¦º´Á¡AÅý¦Û¤v¥Ã¦í¤H¶¡¡C¬JµM¥Í©R¥h¨Ó³o»òµL±`¡A§Ú­Ì§óÀ³¸Ó¦n¦n¦a·R±¤¥¦¡B§Q¥Î¥¦¡B¥R¹ê¥¦¡AÅý³oµL±`¡BÄ_¶Qªº¥Í©R¡A´²µo¥¦¯uµ½¬üªº¥ú½÷¡A¬M·Ó¥X¥Í©R¯u¥¿ªº»ù­È¡C
ªð¦^¦Cªí ¤W¤@¥DÃD