返回列表 上一主題 發帖

status code : 304 是不是爬不下來 ?

回復 1# vanguarx

的確好幾常用的方法抓不下來,不過
以前超級板主程式式碼修改後
尚可抓取
  1. Sub 放榜()
  2.     Cells.Clear
  3.     Application.ScreenUpdating = False
  4.     With CreateObject("internetexplorer.application")
  5.         surl = "https://www.cac.edu.tw/apply108/system/108ColQry_forapply_3r5k9d/html/108_001562.htm"
  6.         .Visible = True
  7.         .Navigate surl
  8.         Application.Wait Now + TimeValue("00:00:01")
  9.          Do While .ReadyState <> 4 Or .Busy: DoEvents: Loop
  10.          
  11.          Application.Wait Now + TimeValue("00:00:01")
  12.         x = .Document.getElementsByTagName("table").Length
  13. '                    For Z = 0 To x - 1
  14. '                        MsgBox "這??第" & Z & "個表格" & Chr(10) & .Document.getElementsByTagName("table")(Z).innerText
  15. '                    Next
  16.         Set shts = ActiveSheet '
  17.         xlHtm = .Document.body.innerHTML
  18.         Set A = .Document.getElementsByTagName("table")
  19.         For xi = st To A.Length - 1 Step 2
  20.             .Document.body.innerHTML = A(xi).outerHTML
  21.             .ExecWB 17, 2       '  Select All
  22.             .ExecWB 12, 2       '  Copy selection
  23.             With shts
  24.                 .Range("A" & .[A65535].End(xlUp).Row + 1).Select
  25.                 .PasteSpecial Format:="HTML", Link:=False, DisplayAsIcon:=False, NoHTMLFormatting:=True
  26.             End With
  27.             .Document.body.innerHTML = xlHtm                  '還原
  28.         Next xi
  29.             .Quit
  30.         End With
  31.     Application.ScreenUpdating = True
  32.    
  33. End Sub
複製代碼

TOP

回復 4# vanguarx

參考看看

http://white5168.blogspot.com/2012/08/excel-vba-js.html

TOP

        靜思自在 : 地上種了菜,就不易長草;心中有善,就不易生惡。
返回列表 上一主題