返回列表 上一主題 發帖

[發問] 在網頁抽取資料時遇到「沒有使用權限」的問題

回復 3# 小俠客

試試看 2003, XP, IE8 下:沒有權限的問題
  1. Option Explicit
  2. Sub EX_IE按下Enter()
  3.     Dim http As Object, i As Integer, A As Object, Result As String
  4.     Set http = CreateObject("InternetExplorer.Application")
  5.     With http
  6.         .Navigate "http://www.hkexnews.hk/sdw/search/search_sdw.asp"
  7.         '.Visible = True
  8.         For i = 1 To 100
  9.             Do While .readyState <> 4 Or .Busy:         DoEvents:    Loop
  10.             .document.getelementbyid("ddlShareholdingDay").Value = 30
  11.             .document.getelementbyid("ddlShareholdingMonth").Value = 11
  12.             .document.getelementbyid("ddlShareholdingYear").Value = 2016
  13.             .document.getelementbyid("txtStockCode").Value = Format(Cells(i, 1), "00000")
  14.             .document.getelementbyid("btnSearch").Click
  15.             Do While .readyState <> 4 Or .Busy:
  16.                 DoEvents
  17.                 If .Busy Then
  18.                     .document.Focus
  19.                     DoEvents
  20.                     Application.SendKeys "{ENTER}", True   '**按下鍵
  21.                 End If
  22.             Loop
  23.             Result = ""
  24.             Do Until InStr(Result, "pnlResult") > 0
  25.                 Result = .document.body.innerhtml
  26.                 If Len(Result) > 0 Then
  27.                     Cells(i, 2) = IIf(InStr(Result, "pnlResult") > 0, "OK", "Not Exist")
  28.                     If InStr(Result, "pnlResult") = 0 Then GoTo Next_StockCode
  29.                 End If
  30.             Loop
  31.             Set A = .document.getelementbyid("pnlResult")
  32.             Do Until InStr(Result, "Remarks:") > 0
  33.                 DoEvents
  34.                 Result = A.innerhtml
  35.             Loop
  36. Next_StockCode:
  37.         Next i
  38.         .Quit
  39.     End With
  40.     MsgBox "OK"
  41. End Sub
複製代碼
感恩的心......(在麻辣家族討論區.用心學習會有進步的)
但資源無限,後援有限,  一天1元的贊助,人人有能力.

TOP

        靜思自在 : 每天無所事事,是人生的消費者,積極、有用才是人生的創造者。
返回列表 上一主題