Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel Visual Basic-简单Web刮刀_Excel_Vba - Fatal编程技术网

Excel Visual Basic-简单Web刮刀

Excel Visual Basic-简单Web刮刀,excel,vba,Excel,Vba,新手问题传入;我正在YouTube上关注一个关于如何从网页上筛选废弃信息的网络系列。目标是能够在我拥有的内部公司应用程序上使用它,该应用程序只显示一个带有文本值的空白网页。然而,两天后我仍然不明白为什么我不能在VB中进行简单的函数调用。到目前为止,当我单击表单上的“Private Sub CommandButton1_click()”按钮时,我所做的一切都会继续抛出编译错误 以下是按钮的代码: Private Sub CommandButton1_Click() 'FirstMacro

新手问题传入;我正在YouTube上关注一个关于如何从网页上筛选废弃信息的网络系列。目标是能够在我拥有的内部公司应用程序上使用它,该应用程序只显示一个带有文本值的空白网页。然而,两天后我仍然不明白为什么我不能在VB中进行简单的函数调用。到目前为止,当我单击表单上的“Private Sub CommandButton1_click()”按钮时,我所做的一切都会继续抛出编译错误

以下是按钮的代码:

Private Sub CommandButton1_Click()
'FirstMacro

    Set objIE = CreateObject("InternetExplorer.Application")
    objIE.Top = 0
    objIE.Left = 0
    objIE.Width = 800
    objIE.Height = 600
    objIE.AddressBar = 0
    objIE.StatusBar = 0
    objIE.Toolbar = 0
    objIE.Visible = True 'We will see the window navigation'

    objIE.Navigate ("http://www.google.com")
    TextBox4.Text objIE.Document.body.innerHTML 
End Sub
下面是该类的代码:

Public Function FirstMacro()
'the_start:

    Set objIE = CreateObject("InternetExplorer.Application")
    objIE.Top = 0
    objIE.Left = 0
    objIE.Width = 800
    objIE.Height = 600
    objIE.AddressBar = 0
    objIE.StatusBar = 0
    objIE.Toolbar = 0
    objIE.Visible = True 'We will see the window navigation'

    'MsgBox.Err.Number

    'On Error Resume Next
       'MsgBox.objIE.Document.body.innerHTML
        'If Err.Number > 0 Then
            'objIE.Quit
            'Set objIE = Nothing
            'GoTo the_start:
        'End If
    
    objIE.Navigate ("http://www.google.com")

    'Do
        'DoEvents
    'Loop Until objIE.ReadyState = 4

    TextBox4.Text objIE.Document.body.innerHTML
End Function
这是我下面的系列:

谢谢你帮了我的忙


你可能应该试试这样的东西

Sub DumpData()

Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True

URL = "http://finance.yahoo.com/q?s=sbux&ql=1"

'Wait for site to fully load
IE.Navigate2 URL
Do While IE.Busy = True
   DoEvents
Loop

RowCount = 1

With Sheets("Sheet1")
   .Cells.ClearContents
   RowCount = 1
   For Each itm In IE.document.all
      .Range("A" & RowCount) = itm.tagname
      .Range("B" & RowCount) = itm.ID
      .Range("C" & RowCount) = itm.classname
      .Range("D" & RowCount) = Left(itm.innertext, 1024)

      RowCount = RowCount + 1
   Next itm
End With
End Sub
然后,您应该对每个URL处理的内容有更好的了解