Web抓取以选择网站中的下拉列表

时间:2019-06-26 08:57:52

标签: excel vba web-scraping

单击按钮元素“ ContentPlaceHolder2_btnSearch”后,元素“ cbSite_I”将返回空白。我希望元素“ cbSite_I”具有值 单击元素“ ContentPlaceHolder2_btnSearch”之后的“ CatLái”。请相应地帮助我。谢谢。

Sub Web()

Dim IE As New SHDocVw.InternetExplorer

On Error GoTo Errorcatch
Application.ScreenUpdating = False

IE.Visible = True

IE.Navigate "https://eport.saigonnewport.com.vn/Pages/Common/Containers_new"

Do While IE.ReadyState <> READYSTATE_COMPLETE Or IE.Busy
DoEvents
Loop

'Application.Wait Now + TimeSerial(0, 0, 5)

IE.document.forms("form2").elements("cbSite_I").Value = "Cát Lái"
IE.document.forms("form2").elements("txtItemNo_I").Value = "MSKU1183832"
IE.document.forms("form2").elements("ContentPlaceHolder2_btnSearch").Click

Do While IE.ReadyState <> READYSTATE_COMPLETE Or IE.Busy
DoEvents
Loop

'Application.Wait Now + TimeSerial(0, 0, 5)

Range("A2").Value = IE.document.getElementById("grdContainer_DXDataRow0").Children(17).textContent

Set IE = Refresh
Set IE = Nothing
IE.Quit

Exit Sub
Errorcatch:
MsgBox Err.Description
Set IE = Nothing
IE.Quit

End Sub

0 个答案:

没有答案