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

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

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

¥»©«³Ì«á¥Ñ GBKEE ©ó 2016-6-17 05:03 ½s¿è

¼Ò¥éª©¤j½s§ï¤@­Óµ{¦¡

¦ý¶×¤J¦³®É·|°±¤î¤¤Â_¡A°±¤îªº¦ì¸m¤£¤@©w

§ÚÃhºÃ¬O°O¾ÐÅ餣¨¬¡A¸Ó¦p¦ó§ï©O¡H
  1. Sub ¾ú¥vªÑ»ù§ó·s()
  2.     Dim xTable As Object, k As Integer, c As Integer, r As Integer, rc As Integer, sn As Integer
  3.     Dim url As String, i As Integer, E As Object
  4.     With Sheets("Àç¹BÁZ®Ä")
  5.           .UsedRange.Clear
  6.     End With
  7.     Sheets("Á`ªí").Select
  8.     rc = Cells(Rows.Count, 1).End(xlUp).Row
  9.     For i = 5 To rc
  10.     sn = Cells(i, 1)

  11.     url = "http://goodinfo.tw/StockInfo/StockBzPerformance.asp?STOCK_ID=" & sn & " &YEAR_PERIOD=10&RPT_CAT=M_YEAR"
  12.          With CreateObject("InternetExplorer.application")
  13.         .Visible = True
  14.         .Navigate url

  15.         Do While .Busy Or .readyState <> 4: DoEvents: Loop
  16.         Set xTable = .Document.getElementsByTagName("TABLE")(11) '¸ê®Æ¦b³o
  17.         With Sheets("Àç¹BÁZ®Ä")

  18.             k = k + 1
  19.             For r = 0 To xTable.Rows.Length - 1
  20.                 For c = 0 To xTable.Rows(r).Cells.Length - 1
  21.                     .Cells(k, c + 1) = xTable.Rows(r).Cells(c).innertext
  22.                 Next
  23.                 k = k + 1
  24.             Next
  25.         End With
  26.         Set xTable = .Document.getElementsByTagName("TABLE")(13) '¸ê®Æ¦b³o
  27.         With Sheets("Àç¹BÁZ®Ä")

  28.             k = k + 1
  29.             For r = 0 To xTable.Rows.Length - 1
  30.                 For c = 0 To xTable.Rows(r).Cells.Length - 1
  31.                     .Cells(k, c + 1) = xTable.Rows(r).Cells(c).innertext
  32.                 Next
  33.                 k = k + 1
  34.             Next
  35.         End With
  36.         Set xTable = .Document.getElementsByTagName("TABLE")(19) '¸ê®Æ¦b³o
  37.         With Sheets("Àç¹BÁZ®Ä")

  38.             k = k + 1

  39.              For r = 0 To 3
  40.                 For c = 0 To xTable.Rows(r).Cells.Length - 1
  41.                     .Cells(k, c + 1) = xTable.Rows(r).Cells(c).innertext
  42.                 Next
  43.                 k = k + 1
  44.             Next
  45.         End With
  46.         .Quit
  47.     End With
  48.     Next
  49. End Sub
½Æ»s¥N½X

¦^´_ 25# GBKEE
ÁÂÁ±z¡I
#15 ~ #20 ¶¡ªº´£°Ý¡A³Ì«á§Ú¬O¥H
  1. .Open "Post", url, False
½Æ»s¥N½X
¨ú¥N¤F
  1. .Open "Get", url, False
½Æ»s¥N½X
¤~±o¥H¸Ñ¨M "&select2=" & TVal(Select_Name)
ªº°Ñ¼Æ¤Þ¤J°ÝÃD¡C
¥i¬O«o¥X²{¼g¤J¤§¤å¦r³¡¤À¬O¤@°ï¶Ã½X¡A
©Ò¥H¤~·|¦A¥á¥X ¥Ñºô­¶¨ú±oªº¸ê®Æ¡A¤£ª¾¹D­n¦p¦ó¦P¨B½s½X¦¨¥¿½T¤§¤¤¤å½X¦^¶Ç
¬ÛÃöªº´£°Ý¡C¤Wºô¬d¬Ý¤F Google/¶Ã½X ªº°Q½×
¦n¦ü¤£¤Ó·f¹Ç¡AÃø¥H¸ÑÃD¡C
ÁÂÁ±z¶O¤ß¦a¦^´_¡C
¤W­z "¦p¦ó¦P¨B½s½X" §Ú¥ç¦³¥[¤J¸É¥R¡A¨Ãªþ¤WÀÉ®×
¦A¦¸ÁÂÁ±z¤F¡I³Â·Ð±z¡I

TOP

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

¦^´_ 15# c_c_lai
À³¹B  ºô­¶¦³¬y¶qºÞ¨î.
1 ÀÉ®×Ãö³¬
2­«¶}ÀÉ®×,   ­«±Òadslªº³s½u,°õ¦æµ{¦¡

¥t³]¤@­Ó­n¶}¶}ÃöÃö goodinfo_¦X¨Ö°]³øÀÉ®× ªºÀÉ®×
ThisWorkbook ¼Ò²Õªºµ{¦¡½X
  1. Option Explicit
  2. Private Sub Workbook_BeforeClose(Cancel As Boolean)
  3.     Application.Quit
  4. End Sub
  5. Private Sub Workbook_Open()
  6.     Dim App As New Application, xFile As String
  7.     xFile = "D:\goodinfo_¦X¨Ö°]³ø.xls"  ' goodinfo_¦X¨Ö°]³øµ{¦¡ªºÀÉ®×
  8.     Application.Visible = False
  9. Re_App:
  10.     With App
  11.         .Visible = True
  12.         .Workbooks.Open (xFile)
  13.     End With
  14.     If App.Visible = False Then
  15.     Set App = Nothing
  16.     GoTo Re_App   
  17.     End If
  18.     ThisWorkbook.Close
  19. End Sub
½Æ»s¥N½X
goodinfo_¦X¨Ö°]³øÀÉ®× ThisWorkbook ¼Ò²Õªºµ{¦¡½X
  1. Option Explicit
  2. Private Sub Workbook_Open()
  3.     adsl³s½u   '°Ñ¦Ò   http://forum.twbts.com/thread-17716-1-1.html ªº adsl³s½uµ{¦¡½X
  4.     goodinfo_¦X¨Ö°]³ø
  5. End Sub
  6. Private Sub Workbook_BeforeClose(Cancel As Boolean)
  7.     Application.Quit
  8. End Sub
  9. Sub goodinfo_¦X¨Ö°]³ø()   
  10.     Dim xTable As Object, k As Integer, C As Integer, sn As Double, r As Integer
  11.     Dim url As String, i As Double, E As Variant
  12.     Dim oXmlhttp As Object, oHtmldoc As Object, surl, op, tm
  13.    For Each E In ThisWorkbook.Names
  14.         If E.Name = "³øªí¶}©l¦C" Then GoTo xStart
  15.    Next
  16.     ThisWorkbook.Names.Add "³øªí¶}©l¦C", 1
  17.     ThisWorkbook.Names.Add "³øªí¶}®É¶¡", Time
  18.     ThisWorkbook.Activate
  19. xStart:
  20.     Sheets("Àç¹BÁZ®Ä").Activate
  21.         With Sheets("Àç¹BÁZ®Ä2")
  22.             .UsedRange.Clear
  23.         End With
  24.     For i = [³øªí¶}©l¦C] To Sheets("Á`ªí").Cells(Rows.Count, 2).End(xlUp).Row '
  25. APP_EX:
  26.         sn = Sheets("Á`ªí").Cells(i, 2)
  27.         url = "http://goodinfo.tw/StockInfo/StockBzPerformance.asp?STOCK_ID=" & sn & "&YEAR_PERIOD=10&RPT_CAT=M_YEAR"
  28.         Set oXmlhttp = CreateObject("msxml2.xmlhttp")
  29.         Set oHtmldoc = CreateObject("htmlfile")
  30.         With oXmlhttp
  31.             .Open "Get", url, False
  32.             .Send
  33.             oHtmldoc.write .responseText
  34.         End With
  35.         Set xTable = oHtmldoc.all.tags("TABLE")
  36.            '*********¥iÆ[¬Ý ¬y¶q³QºÞ¨î ************************************
  37.            Sheets("Àç¹BÁZ®Ä").Cells(i, 1).Resize(, 3) = Array(xTable.Length, sn, Time)
  38.            Sheets("Àç¹BÁZ®Ä").Cells(i, 1).Select
  39.            '************************************************************
  40.               If xTable.Length = 0 Then
  41.                  ThisWorkbook.Names.Add "³øªí¶}©l¦C", i
  42.                  ThisWorkbook.Close True
  43.               End If
  44.             With Sheets("Àç¹BÁZ®Ä2")
  45.             For Each E In Array(11, 13, 19) '11,13,19  "TABLE"
  46.                 k = k + 1
  47.                 For r = 0 To xTable(E).Rows.Length - 1
  48.                 For C = 0 To xTable(E).Rows(r).Cells.Length - 1
  49.                     .Cells(k, C + 1) = xTable(E).Rows(r).Cells(C).innertext
  50.                 Next
  51.                 k = k + 1
  52.                 Next
  53.             Next
  54.         End With
  55.     Next
  56.     ThisWorkbook.Names("³øªí¶}©l¦C").Delete
  57.     MsgBox "¶O®É " & Application.Text(Time - [³øªí¶}®É¶¡], "M¤ÀS¬í") & " Finished Complete!"
  58. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 23# stillfish00
«D±`ÁÂÁ§A¡I
¤§«e¸I¨ìªº½m²ß³£¬O±µÄ²¨ì Get¡A
©Ò¥H¤]¨S¯d·N¦p¦ó¥hÀ³¥Î Post ªº³B­ù¡A
·PÁ§Aªº«ü¾É¡C   ¥Ø«e
TVal = Array("MS", "ALL", "0049", "0099P", "019919T", "0999", "0999P", "01", "02", "03", _
                "04", "05", "06", "07", "21", "22", "08", "09", "10", _
                "11", "12", "13", "24", "25", "26", "27", "28", "29", _
                "30", "31", "14", "15", "16", "17", "18", "23", "9299", "19", "20", "CB")
¥Ø«e´N¥u³Ñ¤U "ALL" (¥þ³¡) ªº°ÝÃD¤´§ì¤£¨ì¡A¨ä¾l³£ OK¡A©Î³\¥N½X¤£¹ï§í©Î¬O . . . . .

§Ú¦AÄ~Äò¥[ªo§a¡C
¦A¦¸ÁÂÁ§AÅo¡I

TOP

¦^´_ 20# c_c_lai
¥i¥Hµy·L°Ñ¦Ò³o©« : http://forum.twbts.com/viewthread.php?tid=15544
  1. Sub Test()
  2.     Dim xTable As Object, k As Integer, C As Integer, R As Integer        '  , sn As Integer
  3.     Dim url As String, cts As Integer, E As Variant, xDate As String      '  , rc As Integer
  4.     Dim oXmlhttp As Object, oHtmldoc As Object, select2 As String         '  , tm
  5.     Dim TVal() As Variant

  6.     If Select_Name = -1 Then Exit Sub
  7.     TVal = Array("MS", "ALL", "0049", "0099P", "019919T", "0999", "0999P", "01", "02", "03", _
  8.                 "04", "05", "06", "07", "21", "22", "08", "09", "10", _
  9.                 "11", "12", "13", "24", "25", "26", "27", "28", "29", _
  10.                 "30", "31", "14", "15", "16", "17", "18", "23", "9299", "19", "20", "CB")

  11.     url = "http://www.twse.com.tw/ch/trading/exchange/MI_MARGN/MI_MARGN.php"
  12.     xDate = Format(Sheets("Á`ªí").[B1], "EE/MM/DD")
  13.     sPost = "qdate=" & Replace(xDate, "/", "%2F") & "&selectType=" & TVal(Select_Name)  'urlencode
  14.     Set oXmlhttp = CreateObject("msxml2.xmlhttp")
  15.     Set oHtmldoc = CreateObject("htmlfile")
  16.     With oXmlhttp
  17.         .Open "Post", url, False
  18.         '.setRequestHeader "Connection", "Keep-Alive"   'µu®É¶¡¤º¦h¦¸¬d¸ß«Øij¥i¥[³o¦æ
  19.         .setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
  20.         .setRequestHeader "Content-Length", Len(sPost)
  21.         .Send sPost
  22.         '¤W­± Open °Ñ¼Æ¥ÎFalse(=¦P¨B)¡A¥i¥H¤£¥Î¦A§PÂ_status
  23.         'Do While .Status <> 200 Or .readyState <> 4: DoEvents: Loop
  24.         oHtmldoc.write .responseText
  25.         'MsgBox .responseText
  26.     End With

  27.     Set xTable = oHtmldoc.ALL.tags("TABLE")
  28.     ' Stop
  29.     '  ¬Ý¬Ý°Ï°ìÅܼƵøµ¡ xTable ªº¤º®e
  30.     Set xTable = oHtmldoc.ALL.tags("TABLE")(0)
  31.     ' Stop
  32.     '  ¦A¦¸¬Ý¬Ý°Ï°ìÅܼƵøµ¡ xTable ªº¤º®e
  33.     MsgBox xTable.INNERTEXT
  34. End Sub
½Æ»s¥N½X
ªí¹F¤£²M¡BÃD·N¤£©ú½T¡B¨SªþÀɮ׮榡¡B¨S¦³°Q½×°ÝÃDªººA«×~~~~~~¥H¤W·R²ö¯à§U¡C

TOP

¦^´_ 21# stillfish00
½Ð±ÐÀ³¦p¦ó¸Ñ¨M©O¡H
§x³n§Ú¦h¤é¤F¡C
ÁÂÁ©p¡I

TOP

¦^´_ 20# c_c_lai
¬Ý¤W¹Ï106¦æ form method="post"
»¡©ú·í§AÂI¬d¸ß®É¬O¥Hpost¶Ç°e½Ð¨D¡A©Ò¥H§A¤£¯à¥u¥Îget¦bºô§}¥[°Ñ¼Æ¡C
ªí¹F¤£²M¡BÃD·N¤£©ú½T¡B¨SªþÀɮ׮榡¡B¨S¦³°Q½×°ÝÃDªººA«×~~~~~~¥H¤W·R²ö¯à§U¡C

TOP

¦^´_ 17# GBKEE

TOP

¦^´_ 17# GBKEE
´ú¸Õ¥Î (¤w®M¥Î±z«Øij¤§¨ç¼Æ)
  1. Sub Test()
  2.     Dim xTable As Object, k As Integer, C As Integer, R As Integer        '  , sn As Integer
  3.     Dim url As String, cts As Integer, E As Variant, xDate As String      '  , rc As Integer
  4.     Dim oXmlhttp As Object, oHtmldoc As Object, select2 As String         '  , tm
  5.     Dim TVal() As Variant
  6.    
  7.     If Select_Name = -1 Then Exit Sub
  8.     TVal = Array("MS", "ALL", "0049", "0099P", "019919T", "0999", "0999P", "01", "02", "03", _
  9.                 "04", "05", "06", "07", "21", "22", "08", "09", "10", _
  10.                 "11", "12", "13", "24", "25", "26", "27", "28", "29", _
  11.                 "30", "31", "14", "15", "16", "17", "18", "23", "9299", "19", "20", "CB")
  12.    
  13.     xDate = Format(Sheets("Á`ªí").[B1], "EE/MM/DD")
  14.     url = "http://www.twse.com.tw/ch/trading/exchange/MI_MARGN/MI_MARGN.php?qdate=" & xDate & "&selectType=" & TVal(Select_Name)
  15.     'url = "http://www.twse.com.tw/ch/trading/exchange/MI_MARGN/MI_MARGN.php?qdate=" & xDate & "&selectType=" & Select_Name
  16.     'url = "http://www.twse.com.tw/ch/trading/exchange/MI_MARGN/MI_MARGN.php?qdate=" & xDate & "&selectType=¤ôªd¤u·~"
  17.     Set oXmlhttp = CreateObject("msxml2.xmlhttp")
  18.     Set oHtmldoc = CreateObject("htmlfile")
  19.     With oXmlhttp
  20.         .Open "Get", url, False
  21.         .Send
  22.         
  23.         Do While .Status <> 200 Or .readyState <> 4: DoEvents: Loop
  24.         
  25.         oHtmldoc.write .responseText
  26.         'MsgBox .responseText
  27.     End With
  28.    
  29.     Set xTable = oHtmldoc.ALL.tags("TABLE")
  30.     ' Stop
  31.     '  ¬Ý¬Ý°Ï°ìÅܼƵøµ¡ xTable ªº¤º®e
  32.     Set xTable = oHtmldoc.ALL.tags("TABLE")(0)
  33.     ' Stop
  34.     '  ¦A¦¸¬Ý¬Ý°Ï°ìÅܼƵøµ¡ xTable ªº¤º®e
  35.     MsgBox xTable.INNERTEXT
  36. End Sub

  37. Private Function Select_Name() As Integer
  38.     With Sheets("Á`ªí").ComboBox1
  39.         If .ListIndex = -1 Then MsgBox ("±z©|¥¼¿ï¾Ü¡u²£·~Ãþ§O¡v¡A½Ð©ó" & vbCrLf & "½T»{«á¦A¦¸ÂI¿ï¡y¶}±Òºô­¶¡z¡A" & vbCrLf & "ÁÂÁ±z¡I")
  40.         Select_Name = .ListIndex    '  Select_Name = -1,0,1,2,3,4,5,6,7,8,9,.....39
  41.     End With
  42. End Function
½Æ»s¥N½X

TOP

¦^´_ 17# GBKEE
¦n«Øij¦¬¨ì¤F¡A©â®É¶¡¦A¨Ó¸Õ¸Õ¾ã¦X«á¤§®ÄªG¡A
­ì¥»¸Ì­±ªº¥DÃD¼Ò²Õ¬O¦U¦Û¿W¥ßªºÀ³¥Î´ú¸Õ¡A
¬ðµo©_·Q¡A¦pªG¦P¤@¥DÃD§¡¤À§O¨Ï¥Î¤£¦P³B²z¤è¦¡¡A
¦p CreateObject("InternetExplorer.Application")¡B
.QueryTables.Add()¡B¥H¤Î CreateObject("msxml2.xmlhttp")
»P CreateObject("htmlfile") ·f°tÀ³¥Îµ¥¡A¨ÃÆ[¹î¥¦­Ì¦P®É¥~³¡
±a¤J°Ñ¼Æ¡B¦p url = "http://www.twse.com.tw/ch/trading/exchange/MI_MARGN/MI_MARGN.php?qdate=" & xDate & "&selectType=" & select2
©Î¤º³¡³B²z¤è¦¡¡A¦p .Document.ALL("input_date").Value = xDate
.Document.ALL("select2").SelectedIndex = i  ¥H¤Î¤º³¡Ä²µo¤§
.Document.ALL("login_btn").Click µ¥ªº¤£¦PÀ³¥Î¡A±q¨ä¦U§Oªº¨¤«×
¨Óµû¦ô°õ¦æ¦¨®Äªº¡C¨ÃÂǦ¹¥ç¥i±Òµo¤j®aªºª¾ªºÅv¯q¤Î¦h¤è¤§À³¥Î¡C
ÁÂÁ±zÅo¡I

TOP

        ÀR«ä¦Û¦b : ­n¥Î¤ß¡A¤£­n¾Þ¤ß¡B·Ð¤ß¡C
ªð¦^¦Cªí ¤W¤@¥DÃD