我正在尝试填写网页上的搜索框,当它被填充时,它会自动搜索结果。网站是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
[在这里阅读了一些帖子(我现在找不到)之后,我的想法是,有/需要将事件监听器和函数包含在此代码中,但这超出了我的脑海。有人可以帮我解决这个问题。
蒂姆·威廉姆斯(Tim Williams)在这里有一篇帖子(对帖子的回答),对此进行了讨论,但现在找不到了。
我正在尝试填写网页上的搜索框,当它被填充时,它会自动搜索结果。该网站为https://pcpartpicker.com/products/motherboard/。如果您去那里并输入...