Anyone know why there is no response from the web for
ClassName: ("J_SearchIpt search-btn iconfont-sf icon-sousuo")
OR
TagName: ("button").
Thank you so much!
And after clicking the button, a new tab pop out. if i want to refer to the new tab, is my code correct as well.
Thank you!
Sub taobao()
Application.ScreenUpdating = False Application.Calculation = xlCalculationManual
Dim i As Integer
Dim x As Integer
Dim k As Integer
Dim pricehq As String
Dim price As String
x = InputBox("initial:")
k = InputBox("final:")
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
On Error Resume Next
For i = x To k
Dim properties As String
properties = Cells(i, 1).Value
'MsgBox properties
IE.navigate "https://sf.taobao.com/?spm=a213w.7398504.sfhead2014.2.1vQXr0¤t=index"
Application.Wait (Now + TimeValue("0:00:07"))
Dim Doc As HTMLDocument
Set Doc = IE.document
Set ptyinput = IE.document.getElementById("J_SearchTxt")
ptyinput.Value = properties
Application.Wait (Now + TimeValue("0:00:02"))
'Set ptyclick = IE.document.getElementByClassName("J_SearchIpt search-btn iconfont-sf icon-sousuo")
Set ptyclick = IE.document.getElementsByTagName("button")
ptyclick.Click
Application.Wait (Now + TimeValue("0:00:03"))
Dim objshell As Object
Set objshell = CreateObject("Shell.Application")
Set IE = objshell.Windows(1)
Application.Wait (Now + TimeValue("0:00:03"))
price = Trim(Doc.getElementsByClassName("price")(0).innerText)
If IsNumeric(Right(price, 1)) = True Then
Cells(i, 2).Value = price
Else
Cells(i, 2).Value = Trim(Doc.getElementById("price_hq").innerText)
price = ""
pricehq = ""
End If
Next i
Application.ScreenUpdating = True Application.Calculation = xlCalculationAutomatic
MsgBox ("Done!")
End Sub