我正在尝试填写网页上的搜索框,当它被填写时,它会自动搜索结果。该网站是https://pcpartpicker.com/products/motherboard/。如果您去那里输入主板名称的主板制造商,您会看到它如何开始缩小可能的选择范围。我有将填充搜索框的代码,但没有任何反应。
Sub GetMotherboards()
Dim ie As InternetExplorer
Set ie = New InternetExplorer
Dim doc As HTMLDocument
Dim objText As DataObject
Dim objArticleContents As Object
Dim objLinksCollection As Object
Dim objToClipBoard As DataObject
Dim r As Object
Dim prodRating As String
Dim prodName As String
Dim lngNumberOfVideos As Long
Dim strURL As String
Dim strNewString As String, strStr As String, strTestChar As String
Dim bFlag As Boolean
strURL = "https://pcpartpicker.com/products/motherboard/" ' Range("J5").Value
With ie
.navigate strURL
.Visible = True
Do While .readyState <> 4: DoEvents: Loop
Application.Wait Now + #12:00:02 AM#
Set doc = ie.document
End With
bFlag = False
With doc
Set objArticleContents = .getElementsByClassName("subTitle__form")
Stop
Set ele = .getElementsByClassName("subTitle__form")(0)
Set form = .getElementsByClassName("subTitle__form")(0).getElementsByClassName("form-label xs-inline")(1)
Set inzputz = ele.getElementsByClassName("text-input")(0)
Call .getElementsByClassName("text-input")(0).setAttribute("placeholder", "MSI B450 TOMAHAWK") '.setAttribute("part_category_search", "MSI B450 TOMAHAWK")
End With
End Sub
在这里阅读了一些帖子(我现在找不到)之后,我的想法是有/有事件侦听器和函数需要包含在此代码中,但这超出了我的想象。有人可以帮我解决这个问题。
蒂姆威廉姆斯在这里有一个帖子(帖子的答案)讨论了这个但现在我找不到它。