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

[µo°Ý] ½Ð±Ðºô­¶®»¨úªº°ÝÃD¡H CreateObject("msxml2.xmlhttp") ªº°ÝÃD?

[µo°Ý] ½Ð±Ðºô­¶®»¨úªº°ÝÃD¡H CreateObject("msxml2.xmlhttp") ªº°ÝÃD?

½Ð±Ðºô­¶®»¨úªº°ÝÃD¡H CreateObject("msxml2.xmlhttp") ªº°ÝÃD?
  1. Sub test() '¨ú·l¯qªí(¦~ªí)ºô­¶
  2. Dim Url, HTMLsourcecode, GetXml, TableG, i, j
  3. Set HTMLsourcecode = CreateObject("htmlfile")
  4. Set GetXml = CreateObject("msxml2.xmlhttp")
  5. Url = "http://kgieworld.moneydj.com/z/zc/zcq/zcqa/zcqa_2330.djhtm"
  6. With GetXml
  7. .Open "GET", Url, False
  8. .send

  9. ' Debug.Print .document.all(0).getElementsByTagName("div")(0).outerHTML
  10.   ' Debug.Print .document.all(0).getElementsByClassName("t11")(0).outerHTML
  11. ' Debug.Print .document.all(0).getElementsByClassName("table-row")(11).outerHTML
  12. '  Debug.Print .document.all(0).getElementsByClassName("t4t1 table-cell")(2).outerHTML
  13.   'Debug.Print .document.all(0).getElementsByClassName("t3n1 table-cell")(0).outerHTML
  14.   'Debug.Print .document.all(0).getElementsByClassName("t3n1 table-cell")(482).outerHTML
  15.   Debug.Print .document.all(0).getElementsByClassName("t3n1 table-cell")(482).innerHTML

  16. Debug.Print "test"
  17. End With
  18. Set HTMLsourcecode = Nothing 'ÄÀ©ñ°O¾ÐÅé
  19. Set GetXml = Nothing
  20. End Sub '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
½Æ»s¥N½X
½Ð±Ð¤j¤j¡Aºô­¶§ïª©¡A¸Õ­×§ïµ{¦¡¡ADebug.Print .document.all(0).getElementsByClassName("t3n1 table-cell")(482).innerHTML
¥ÎCreateObject("InternetExplorer.Application")¥i°õ¦æ¡A¥ÎCreateObject("msxml2.xmlhttp") ·|¿ù»~¡A½Ð°Ý¦p¦ó­×§ï¡AÁÂÁÂ

¦^´_ 22# GBKEE


    ÁÂÁ ª©¤j §ï¹L´N¥i¥H¤F¡A ±q¤¤¾Ç²ß«Ü¦h
  1.        Do  '  µ{¦¡¹B¦æ³t«×§Ö¥Î°j°é,½T«OTableGª«¥ó¤U¸ü§¹¾ã
  2.             Set TableG = HTMLsourcecode.all.tags("div")
  3.             DoEvents
  4.             N = N + 1
  5.             '**   "JScriptTypeInfo"  ¥i¦b °Ï°ìÅܼƵøµ¡ ¬d¬Ý
  6.             Debug.Print TypeName(TableG) & N
  7.             '** ©Î¬O   Debug.Print TypeName(TableG) ±oª¾
  8. '        Loop Until TypeName(TableG) = "JScriptTypeInfo"
  9.         Loop Until TypeName(TableG) = "DispHTMLElementCollection"
½Æ»s¥N½X

TOP

¦^´_ 22# GBKEE


ÁÂÁ ª©¤j
F8 °õ¦æ

ª«¥ó¦WºÙ¤£¤@¼Ë
Object/DispHTMLElementCollection

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2022-1-12 13:53 ½s¿è

¦^´_ 21# wufonna

   
¤W¹Ï§APCÀô¹Ò¤¤ TypeName(TableG)
¤U¹Ï§ÚPCÀô¹Ò¤¤ µ{¦¡½XTypeName(TableG) ¤£¤@¼Ë
³o¸Ì­n­×§ï¤@¤U

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

TOP

¦^´_ 20# GBKEE


    ÁÂÁ ª©¥D¡A§Ú°õ¦æµ{¦¡¨S°±¤î¡A¥Î debug ´ú¸Õ¡A¦b³o¬q¸Ì°j°é
  1.        Do  '  µ{¦¡¹B¦æ³t«×§Ö¥Î°j°é,½T«OTableGª«¥ó¤U¸ü§¹¾ã
  2.             Set TableG = HTMLsourcecode.all.tags("div")
  3.             DoEvents
  4.             '**   "JScriptTypeInfo"  ¥i¦b °Ï°ìÅܼƵøµ¡ ¬d¬Ý
  5.             '** ©Î¬O   Debug.Print TypeName(TableG) ±oª¾
  6.             N = N + 1
  7.             
  8.             Debug.Print TypeName(TableG) & N
  9.         Loop Until TypeName(TableG) = "JScriptTypeInfo"
½Æ»s¥N½X

Image 1.jpg (161.21 KB)

Image 1.jpg

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2022-1-12 10:00 ½s¿è

¦^´_ 18# wufonna
¦h¼g´X¦æ¸Õ¸Õ¸Õ¸Õ¬Ý
  1. Private Sub GetIncome() '¨ú·l¯qªí(¦~ªí)ºô­¶
  2.     Dim Url, HTMLsourcecode, GetXml, TableG As Object, i As Integer, j As Integer, a As Integer
  3.     Set HTMLsourcecode = CreateObject("htmlfile")
  4.     Set GetXml = CreateObject("msxml2.xmlhttp")
  5.     Url = "http://kgieworld.moneydj.com/z/zc/zcq/zcqa/zcqa_2330.djhtm"
  6.     With GetXml
  7.         .Open "GET", Url, False
  8.         .send
  9.         HTMLsourcecode.write .Responsetext
  10.         Do  '  µ{¦¡¹B¦æ³t«×§Ö¥Î°j°é,½T«OTableGª«¥ó¤U¸ü§¹¾ã
  11.             Set TableG = HTMLsourcecode.all.tags("div")
  12.             DoEvents
  13.             '**   "JScriptTypeInfo"  ¥i¦b °Ï°ìÅܼƵøµ¡ ¬d¬Ý
  14.             '** ©Î¬O   Debug.Print TypeName(TableG) ±oª¾
  15.         Loop Until TypeName(TableG) = "JScriptTypeInfo"   
  16.           '*****±oª¾ classname="table-row" ªº¦ì¸m
  17.         For a = 0 To TableG.Length - 1
  18.             'Debug.Print a, TableG(a).classname
  19.             If TableG(a).classname = "table-row" Then Exit For   'Ū¨ú¸ê®Æ°_©l¦C¼Æ
  20.         Next
  21.         '***************************************
  22.        With ActiveSheet
  23.             .Cells.Clear
  24.             For i = a To TableG.Length - 1
  25.                 For j = 0 To TableG(i).all.tags("span").Length - 1
  26.                     .Cells(i - (a - 1), j + 1) = TableG(i).all.tags("span")(j).innertext
  27.                     '****** i - ( a-1) >>­×¥¿±q²Ä¤@¦C¶}©l¤U¸ü¸ê®Æ
  28.                 Next j
  29.             Next i
  30.         End With
  31.         '***ºô­¶ªº½s½X**********************************
  32.         '<div class="table-row">   ¬°©Ò­nªº¸ê®Æ ªººô­¶¤¸¯À
  33.         '<span class="t2 table-cell">´Á§O</span>
  34.         '<span class="t2 table-cell">2020</span>
  35.         '<span class="t2 table-cell">2019</span>
  36.         '<span class="t2 table-cell">2018</span>
  37.         '<span class="t2 table-cell">2017</span>
  38.         '<span class="t2 table-cell">2016</span>
  39.         '<span class="t2 table-cell">2015</span>
  40.         '<span class="t2 table-cell">2014</span>
  41.         '<span class="t2 table-cell">2013</span>
  42.         '</div>************************************
  43.     End With
  44.     Set HTMLsourcecode = Nothing 'ÄÀ©ñ°O¾ÐÅé
  45.     Set GetXml = Nothing
  46. End Sub '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 14# GBKEE


    ³o¦¸ºô­¶§ïª©¡A§ì¨úªº¦³ªºªÑ²¼¦æ¼Æ¤£¦P¡A¹³ª÷¿ÄªÑ¨º¤@¬q¨úB67Äæ´N¤£¦b¨º¦æ¡A´N¹Á¸Õ¥Îfind ,¥þ³¡¤W¥«¥i¥H¶]§¹¡C

TOP

¦^´_ 14# GBKEE
  1. Sub GetIncome() '¨ú·l¯qªí(¦~ªí)ºô­¶
  2. Dim Url, HTMLsourcecode, GetXml, TableG, i, j
  3. Set HTMLsourcecode = CreateObject("htmlfile")
  4. Set GetXml = CreateObject("msxml2.xmlhttp")
  5. Url = "http://kgieworld.moneydj.com/z/zc/zcq/zcqa/zcqa_2330.djhtm"
  6. With GetXml
  7. .Open "GET", Url, False
  8. .Send
  9. HTMLsourcecode.body.innerhtml = .Responsetext
  10. Set TableG = HTMLsourcecode.getelementsbyclassname("table-row")
  11. '***ºô­¶ªº½s½X**********************************
  12. '<div class="table-row">   ¬°©Ò­nªº¸ê®Æ ªººô­¶¤¸¯À
  13. '<span class="t2 table-cell">´Á§O</span>
  14. '<span class="t2 table-cell">2020</span>
  15. '<span class="t2 table-cell">2019</span>
  16. '<span class="t2 table-cell">2018</span>
  17. '<span class="t2 table-cell">2017</span>
  18. '<span class="t2 table-cell">2016</span>
  19. '<span class="t2 table-cell">2015</span>
  20. '<span class="t2 table-cell">2014</span>
  21. '<span class="t2 table-cell">2013</span>
  22. '</div>************************************
  23. For i = 0 To TableG.Length - 1
  24.     For j = 0 To TableG(i).all.tags("span").Length - 1
  25.        Cells(i + 1, j + 1) = TableG(i).all.tags("span")(j).innertext
  26.     Next j
  27. Next i
  28. End With
  29. Set HTMLsourcecode = Nothing 'ÄÀ©ñ°O¾ÐÅé
  30. Set GetXml = Nothing
  31. End Sub '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
½Æ»s¥N½X
½Ð±Ð ª©¤j §Ú office 2007 ª© ´ú¸Õ µ{¦¡
Set TableG = HTMLsourcecode.getelementsbyclassname("table-row")
³o¦æ·|»~¡A¬O§_ª©¥»ªº°ÝÃD
ÁÂÁ ª©¤j

Image 7.jpg (95.22 KB)

Image 7.jpg

TOP

¦^´_ 15# GBKEE


    ÁÂÁ 娰¥D µ{¦¡ ¡A ¾Ç²ß¤¤ ¡C

googs.jpg (210.53 KB)

googs.jpg

TOP

¦^´_ 14# GBKEE


    ÁÂÁ ª©¥D  ±q ¤¤¾Ç¨ì«Ü¦h¡C

TOP

        ÀR«ä¦Û¦b : ¤@­Ó¯Ê¤fªºªM¤l¡A¦pªG´«¤@­Ó¨¤«×¬Ý¥¦¡A¥¦¤´µM¬O¶êªº¡C
ªð¦^¦Cªí ¤W¤@¥DÃD