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

[µo°Ý] IE¤w³]©w.Visible¤´¸õ¥Xºô­¶

[µo°Ý] IE¤w³]©w.Visible¤´¸õ¥Xºô­¶

½Ð±Ð¤@¤U¦U¦ìVBA°ª¤â¡A§Q¥ÎVBAµ{¦¡¶}±Òºô­¶¾Þ§@³o­Ó§Ú·|
ºô­¶¤]³]©wVisible=False¤F¡A¦ý¦P¼Ëµ{¦¡½X¦b¤£¦P¹q¸£°õ¦æ®É
«o·|¦³¤£¦Pµ²ªG¡A¦³®Éºô­¶·|¸õ¥X¨Ó¡A¦³®É«h¤£·|
³oÅý§ÚÁÙÆZ§x´bªº¡A¦]¬°¨C¦¸ºô­¶¸õ¥Xªº®É­Ô¡AVBAµ{¦¡³£·|¥X¿ù
¬O»Ý­n°µ¤°»ò³]©wÁÙ¬O¥i¥H¥[¤J¤°»òµ{¦¡½X¡AÅýºô­¶¦Ê¤À¤§¦Ê¤£·|¸õ¥X
§Æ±æ¦³°ª¤â¥i¥HÀ°¦£¸Ñ´b¤@¤U¡A«D±`·PÁ¡C
  1. Sub test()
  2. Set IE = CreateObject("InternetExplorer.Application")
  3.     With IE
  4.         .Visible = True
  5.         .Navigate "https://www.tpex.org.tw/web/stock/statistics/monthly/st44.php?l=zh-tw"
  6.         Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
  7.     End With
  8. End Sub
½Æ»s¥N½X

§Ú¤@ª½»{¬° excel vba ±±¨îºô­¶ ³£¤£¬O¤@­Ó©ú´¼ªº¨M©w
¦]¬°ºô¸ô¤Wªº±Ð¾Ç ¤£¦h ¦Ó¥B¹ï­è¤J¤âªº¥Î¤á½ÆÂø
§Ú¤§«e¤]»Ý­n¦n¹³§A¨º¼Ëªº»Ý­n
§Ú¹Á¸Õ¤Fpython  ¤ñ§Ú·Q¹³¤¤®e©ö¥Î ¸ò²z¸Ñ  ¦pªG¤¹³\ §A¥i¥H¸Õ¸Õ

TOP

¥»©«³Ì«á¥Ñ smart3135 ©ó 2020-1-25 00:06 ½s¿è
§Ú¤@ª½»{¬° excel vba ±±¨îºô­¶ ³£¤£¬O¤@­Ó©ú´¼ªº¨M©w
¦]¬°ºô¸ô¤Wªº±Ð¾Ç ¤£¦h ¦Ó¥B¹ï­è¤J¤âªº¥Î¤á½ÆÂø
§Ú ...
adrian_9832 µoªí©ó 2020-1-22 07:58

±z¦n¡A§Úª¾¹Dpython¨ä¹ê«Ü¦n¥Î¡A¥u¬O¦]¬°¤½¥q¦b¤u§@¤W¥u¯à¨Ï¥ÎEXCEL
¨S¿ìªk¥t¥~¸Ë¨ä¥L³n¥ó¡A©Ò¥H¤]¨S¿ìªk¥Îpython¡A¥Ø«e¬Oª¦¤F´X¤ÑGoogle¤j¯«
¶È¦³¦bhttp://coding-warehouse.logdown.com/posts/193504-get-ie§ä¨ì¸Ñ¨M¤èªk
¦ý¤½¥qªº¹q¸£³o¼Ë³]©w¤£¬O«Ü«ê·í¡A¦³¸Õ¹L¦bµ{¦¡½X¤¤¥[¤JIE.Quit©ÎSet IE=Nothing
¨Ì·|¥X¿ù¡A¤£ª¾¬O§_ÁÙ¦³¨ä¥L¤è¦¡

°õ¦æµ{¦¡½X¥X¿ù


¥Ø«e°ß¤@§ä¨ìªº¸Ñ¨M¤èªk

TOP

½Ð±Ð¤@¤U¦U¦ìVBA°ª¤â¡A§Q¥ÎVBAµ{¦¡¶}±Òºô­¶¾Þ§@³o­Ó§Ú·|
ºô­¶¤]³]©wVisible=False¤F¡A¦ý¦P¼Ëµ{¦¡½X¦b¤£¦P¹q ...
smart3135 µoªí©ó 2020-1-21 23:35
  1. Sub test()
  2.     ¦~ = 2019
  3.     ªÑ²¼¥N½X = 1259
  4.     Cells.Clear
  5.     Dim oXML As Object
  6.     Set oXML = CreateObject("WinHttp.WinHttpRequest.5.1")

  7.     Dim oHTML As Object
  8.     Set oHTML = CreateObject("HTMLFile")

  9.     With oXML
  10.         .Open "POST", "https://www.tpex.org.tw/web/stock/statistics/monthly/result_st44.php?l=zh-tw", 0
  11.         .setRequestHeader "Content-Type", "application/x-www-form-urlencoded;"
  12.         .setRequestHeader "Origin", "https://www.tpex.org.tw"
  13. '        .send "ajax=true&l=zh-tw&yy=2020&input_stock_code=1258"
  14.         .send "ajax=true&l=zh-tw&yy=" & ¦~ & "&input_stock_code=" & ªÑ²¼¥N½X
  15.         oHTML.body.innerHTML = convertraw(.responseBody, "UTF-8")
  16.         Debug.Print oHTML.body.innerHTML
  17.     End With

  18.     Dim oTable As Object, oRow As Object, oCell As Object
  19.     Dim i As Integer, j As Integer

  20.     Set oTable = oHTML.getElementsByTagName("table")(2)
  21.     i = 1
  22.     For Each oRow In oTable.Rows
  23.         j = 1
  24.         For Each oCell In oRow.Cells
  25.             Cells(i, j).Value = oCell.innerText
  26.             j = j + 1
  27.         Next oCell
  28.     i = i + 1
  29.     Next oRow

  30.     Set oHTML = Nothing
  31.     Set oXML = Nothing
  32. End Sub

  33. Function convertraw(rawdata, char)
  34.     Dim rawstr
  35.     Set rawstr = CreateObject("adodb.stream")
  36.     With rawstr
  37.       .Type = 1
  38.       .Mode = 3
  39.       .Open
  40.       .Write rawdata
  41.       .Position = 0
  42.       .Type = 2
  43.       .Charset = char
  44.       convertraw = .ReadText
  45.       .Close
  46.     End With
  47.     Set rawstr = Nothing
  48. End Function
½Æ»s¥N½X

TOP

https://play.google.com/books/reader?id=ejyeDwAAQBAJ&hl=zh_TW&pg=GBS.PA22

§A¥i¥H¸Õ¤U¬Ý¤U³o¥»®Ñ   ¥i¯à¦³¨ÇÀ°§Uªº playstore ¦³¸Õ¾\,

¦Ü©ó³Ì«á§Ú¸ò§A¤@¼Ëªº°ÝÃD §Ú°½°½¦b¦Û¤vªº¹q¸£¦w¸Ë python  ¸Ñ¨M¤F «¢«¢  §Ú§Ë¦n°¨¤W´N§â ¶×¥X¦¨EXE  µM«á¸Ñ°£¦w¸Ë¤F

TOP

¦^´_ 4# joey0415
Joey¤j¡A¤£¦n·N«ä¡A¤£¬O«ÜÀ´±z³o¬qµ{¦¡½X¡A¤£ª¾¯à¤£¯à®M¥Î¦b§Úªºµ{¦¡½X©O¡H
  1. Sub ¤u³æÁ`¼Æ¦^³ø()
  2. Set IE = CreateObject("InternetExplorer.Application")
  3.     With IE
  4.         .Visible = False
  5.        .Navigate "¤½¥qºô§}"
  6.         Do While .Busy Or .ReadyState <> 4: DoEvents: Loop

  7.         With .Document
  8.                 .ALL("dFrom").Value = "2020/01/05"    '¶}©l¤é´Á
  9.                 .ALL("dTo").Value = "2020/01/11"    'µ²§ô¤é´Á
  10.                 For Each E In .GetElementsBytagName("INPUT")
  11.                     If E.Value = "¬d¸ß" Then
  12.                         E.Click
  13.                         Exit For
  14.                     End If
  15.                 Next
  16. '                .ALL("¬d¸ß").Click       '«ö¤U¬d¸ßÁä
  17.             End With
  18.             Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
  19.             .execwb 17, 2
  20.             .execwb 12, 2

  21.         With ActiveSheet
  22.             .Cells.Delete
  23.             .[a1].Select
  24.             .PasteSpecial Format:="Unicode ¤å¦r", Link:=False, DisplayAsIcon:= _
  25.             False, NoHTMLFormatting:=True
  26.         End With
  27.     End With
  28. End Sub
½Æ»s¥N½X

TOP

¥»©«³Ì«á¥Ñ joey0415 ©ó 2020-1-31 12:17 ½s¿è
¦^´_  joey0415
Joey¤j¡A¤£¦n·N«ä¡A¤£¬O«ÜÀ´±z³o¬qµ{¦¡½X¡A¤£ª¾¯à¤£¯à®M¥Î¦b§Úªºµ{¦¡½X©O¡H
smart3135 µoªí©ó 2020-1-30 22:02

https://www.tpex.org.tw/web/stock/statistics/monthly/result_st44.php?l=zh-tw

¤W­±ªºµ{¦¡½X¥i¥H§ìºô­¶
¤]¥i¥H«ü©w¤é´Á

ºô­¶ªº§ì¨úªk¤À¦¨

IEªk»PXMLHTTPµ¥´X¤jÃþ
§Ú±Ä¥ÎXMLHTTP¡A§A¦Û¤v¬Ýµ{¦¡½X­×§ï¬Ý¬Ý
¦pªG¬O¤½¥q¤ººô¡A§Ú¨S¦³¬Ý¨ìºô®çµLªkµ¹·N¨£

TOP

¦^´_ 1# smart3135
§A´£¥Xªº³o¬qµ{¦¡§Ú¤]¦³¨Ï¥Î,¨Ã¨S¦³§A»¡ªº±¡ªp
¦Ó¦b¤£¦P¹q¸£°õ¦æ¦³®É·|¥X²{²§±`,¬O¤£¬O¦]¬°¹q¸£®Ä¯à¤£¦P,ºô­¶¶}±Òªº³t«×®t²§³y¦¨
¦]¬°¦³¨Çºô­¶¨ÃµLªk¨Ï¥Î"Do While .Busy Or .ReadyState <> 4: DoEvents: Loop"§PÂ_ºô­¶¬O§_¤w§¹¾ã¶}±Ò
«Øij¥i¼W¥[Application.Wait Now + TimeValue("00:00:30"),¦hµ¥«Ý¤@¨Ç®É¶¡
¦ÓIE.Quit & Set IE=Nothing½Ð¥[©óµ{¦¡³Ì«á­±

TOP

        ÀR«ä¦Û¦b : ªY½à§O¤H´N¬O²øÄY¦Û¤v¡C
ªð¦^¦Cªí ¤W¤@¥DÃD