我有一个代码输入此地址(https://processual.trf1.jus.br/consultaProcessual/numeroProcesso.php?secao=TRF1&enviar=ok)并填入空白处以一个数字(例如1778390520174019198)。之后,我的代码点击了' pesquisar按钮'。然后,我的代码点击了' partes'。
在那之后,它是我需要的信息。在这个例子中(requerente - Jamille Seixas Souza)。
我无法找到将此数据放入Excel工作表的方法。请帮我! 这是我的代码,直到现在。
Dim ie As InternetExplorer
Dim C
Dim numero As String
Dim HTMLDoc As HTMLDocument
Dim objlink As Object
Dim objElementCol As Object
Dim objElement As Object
Dim objeto As Object
numero = Application.InputBox("Por Favor entre com o numero precatorio", "", "")
Set ie = New InternetExplorer
ie.Visible = True
ie.Navigate "https://processual.trf1.jus.br/consultaProcessual/numeroProcesso.php?secao=TRF1&enviar=ok"
ieBusy ie
ie.Document.all("proc").innerText = numero
'obtém o forma a qual o controle de login pertence para submetê-lo
ie.Document.getElementById("enviar").Click
ieBusy ie
Dim elemUnique, elemCollection As Object
Set elemCollection = ie.Document.getElementsByTagName("a")
For Each elemUnique In elemCollection
If elemUnique.innerText Like "Partes" Then
elemUnique.Click
Exit For
End If
Next elemUnique
答案 0 :(得分:0)
好的,让我看看。这里
ie.Document.all("proc").innerText = numero
您可能正在尝试在文本框中键入一些值。它应该是:
Dim iInputBox As IHTMLElement
Set iInputBox = ie.Document.getElementById("proc")
iInputBox.Value = numero
然后你试图点击按钮。这没关系,但您应该给应用程序一些时间来加载站点。添加一段代码
Do Until ie.READYSTATE <> READYSTATE_COMPLETE
DoEvents
Loop
也许你的功能ie.busy也是如此,我不知道,它对我不起作用。然后我们有一个小问题,我不知道结果的网站是怎样的,我在输入框中键入了1234567890,这让我无处可去。当我键入数字1778390520174019198时,某些脚本无法运行。这可能是因为我在防火墙后面。但是,如果在点击&#34; Pesquisar&#34;后,网站中只有一个表格显示,则此代码应该能够获得它。
Dim iTab As IHTMLElement
Dim iTr As IHTMLElement
Dim iTd As IHTMLElement
Dim lRow As Long
Dim lColumn As Long
Application.Wait (Now + TimeSerial(0, 0, 5)) 'lets give script some time to execute
Set iTab = ie.Document.getElementById("aba-processo")
lRow = 1
For Each iTr In iTab.getElementsByTagName("tr")
lColumn = 1
For Each iTd In iTr.getElementsByTagName("td")
Cells(lRow, lColumn).Value = iTd.innerText
lColumn = lColumn + 1
Next iTd
lRow = lRow + 1
Next iTr
最后,你应该关闭IE。
ie.Quit
我希望这会有所帮助。