2
我試圖輸入包裹ID:220022400803300並試圖獲得結果,但即使在將包裹ID放入搜索框並單擊提交按鈕後,它仍未返回結果。如何提交表單數據excel vba
任何人都可以請幫助我,或者如果有更好的方法來做到這一點,請讓我知道。
該網站是http://eringcapture.jccal.org/caportal/CAPortal_MainPage.aspx訪問該網站後我點擊Search your Real Property. Click Here.
在頁面的底部,那麼我選擇parcel #
單選按鈕,然後把那個大包的ID號220022400803300,點擊Search
按鈕,但它不返回結果發現,同時手動將其做給出1個結果。
Option Explicit
Option Compare Text
Dim fRD As Long, i As Long, fSR As Long, j As Long
Dim pID As String
Dim IE As SHDocVw.InternetExplorer
Dim Doc As MSHTML.HTMLDocument
Dim urL As String
Dim fnd As Boolean
Sub genOP()
With RD
fRD = .Range("A" & .Rows.Count).End(xlUp).Row
Set IE = New SHDocVw.InternetExplorer
urL = "http://eringcapture.jccal.org/caportal/CAPortal_MainPage.aspx"
For i = 2 To 2
fSR = SR.Range("A" & SR.Rows.Count).End(xlUp).Row + 1
pID = Trim(Format(.Range("A" & i).Value, "0")) ' get PID
If Len(pID) < 8 Then GoTo nextRow
IE.Visible = True
IE.navigate urL
Call WaitForIE
Set Doc = IE.document
Doc.getElementById("Iframe1").contentDocument.getElementById("RealSearchLink").Click
Call WaitForIE
Doc.getElementById("Iframe1").contentDocument.getElementById("SearchByParcel").Checked = True
'SearchByTB
'Delete the first 2 digits from the excel data (parcel ID), e.g. 22002240080330000000 (instead of 0122002240080330000000)
'pID = Right(pID, Len(pID) - 2)
Doc.getElementById("Iframe1").contentDocument.getElementById("SearchText").Value = pID 'Put id in text box
Doc.getElementById("Iframe1").contentDocument.getElementById("Search").Click 'search button
Call WaitForIE
fnd = False
If Trim(Doc.getElementById("Iframe1").contentDocument.getElementById("TotalRecFound").innerText) = "No Records Found." Then
For j = 1 To 6
pID = Left(pID, Len(pID) - 1)
Doc.getElementById("Iframe1").contentDocument.getElementById("SearchText").Value = pID 'Put id in text box
Doc.getElementById("Iframe1").contentDocument.getElementById("Search").Click 'search button
Call WaitForIE
If Trim(Doc.getElementById("Iframe1").contentDocument.getElementById("TotalRecFound").innerText) <> "No Records Found." Then
'Result Found
Stop
fnd = True
Exit For
End If
Next j
Else
'Result Found
Stop
fnd = True
End If
If Not fnd Then
SR.Range("A" & fSR) = "No Records Found"
End If
nextRow:
Next i
IE.Quit
Set IE = Nothing
End With
MsgBox "Process Completed"
End Sub
Sub WaitForIE()
While IE.Busy Or IE.readyState <> READYSTATE_COMPLETE
DoEvents
Wend
Application.Wait Now + TimeValue("00:00:05")
End Sub
您要導航到的頁面上沒有搜索框。 – sktneer
@sktneer如果您點擊搜索頁面底部的不動產,有一個搜索框 – Rohan