【发布时间】:2019-02-13 22:02:54
【问题描述】:
最近我正在学习使用 excel 宏在网站上进行搜索。我已经阅读了几个论坛主题,并想出了下面的代码。但是,当我到达该行时出现错误
SearchBox(0).Value = SearchString
我试图删除 (0) 但也出现了另一个错误。该代码在其他网站上运行良好。我应该如何改变它们以适应这个网站?
附:我也想知道点击搜索按钮的方法。
Sub Searchstockcode()
Dim SearchString As String
SearchString = "700"
Set ie = CreateObject("InternetExplorer.Application")
With ie
ie.Visible = True
End With
ie.Navigate "http://www.hkexnews.hk/listedco/listconews/advancedsearch/search_active_main.aspx"
While ie.ReadyState <> 4
DoEvents
Wend
Dim SearchBox As Object
Set SearchBox = ie.Document.GetElementsByName("ct100$txt_stock_code")
SearchBox(0).Value = SearchString
Dim SearchButton As Object
Set SearchButton = ie.Document.GetElementsByName
End Sub
【问题讨论】:
-
请与我们分享您收到的确切错误消息。此外,此宏还可以与哪些其他网站配合使用?这样我们就可以比较/对比他们的 html。
标签: excel vba web-scraping