VBA宏excel ..错误无法从页面获取信息

时间:2017-03-27 23:10:01

标签: excel vba excel-vba

无法获取数据

Sub differntIEsize()

    Dim ie As New SHDocVw.InternetExplorer

    Dim doc As HTMLDocument

    Set ie = CreateObject("InternetExplorer.Application")


    With ie
        .Visible = True
        .navigate "https://en.wikipedia.org/wiki/Main_Page"

    Do While .Busy
        DoEvents
    Loop

    Do While .readyState <> 4
        DoEvents
    Loop

    Set searchtxt = .document.getElementById("searchInput")

    searchtxt.Value = "Earth"

    .document.forms(0).submit

    Do While .Busy
        DoEvents
    Loop

    Do While .readyState <> 4
        DoEvents
    Loop

    'IE.navigate "javascript:document.getElementById('.document.forms(0).submit').click();"

    ThisWorkbook.Sheets(1).Range("A2") = "hgvgjjlj"

    Set doc = .document

    ThisWorkbook.Sheets(1).Range("A1").Value = doc.getElementById("toctitle").innerText

    .Quit
    End With

End Sub

0 个答案:

没有答案