This commit is contained in:
louiscklaw
2025-02-01 01:59:56 +08:00
parent b3da7aaef5
commit 8719fe58b8
310 changed files with 6332 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
Attribute VB_Name = "example_amazon"
Const css_input = "#twotabsearchtextbox"
Const css_spinner = "#centerBelowPlusspacer"
Const css_titles = "#s-results-list-atf a.s-access-detail-page"
Const css_bt_next = "#pagnNextLink #pagnNextString"
Private Sub Search_Amazon()
Const search_input = "drum carrot"
Dim driver As New ChromeDriver
driver.Get "http://www.amazon.com/s"
' type in the field and submit
driver.FindElementByCss(css_input) _
.SendKeys(search_input) _
.Submit
Dim By As New By
Do
' wait for the loading bar to disapear
driver.WaitNotElement By.css(css_spinner), 7000
' handle results
For Each ele In driver.FindElementsByCss(css_titles)
Debug.Print ele.Text
Next
' click next page or exit the loop if the link is not present
Set bt_next = driver.FindElementByCss(css_bt_next, timeout:=0, Raise:=False)
If bt_next Is Nothing Then _
Exit Do
bt_next.Click
Loop
End Sub