J
Juan Jose Costello Levien
Hello,
My name is Juan. I am new to the forum.
Here I leave you a problem to see if you can help me.
General Description
I am developing an application in Visual Basic 6.
The program has to consult an ASP page of a public argentinian service
called ANSES, obtain a result from the response (the query is done by
completing a form).
The program sends the query with an Internet Transfer Control and the POST
method supported.
Up to here, all goes Ok.
The problem is that sometimes, the query result may not finish in the result
page, but the ASP server can respond as result a page with links. And
clicking on those links makes appear the final desired result.
So, my program detects if the response is effectively the final query result
or a link form to click inside. This does it Ok.
The problem is that I do not know to simulate a click on a corresponding
form link with Visual Basic code, or simulate the submit method from that
control with POST.
I have tried with many entry data but no way.
Details
Data form filling page:
http://www.anses.gov.ar/expedientes.htm
ASP page:
http://www.anses.gov.ar/servicios/IGTPC/Consulta.aspx
Visual Basic code to automate the query response:
Private Sub Command4_Click()
Dim str As String
Dim data As String
Dim bData() As Byte
Dim num As Long
Dim j As Long
Dim count As Long
'completa los datos del formulario de expedientes
data = "txtDoc=6903892&" & _
"TipoTramite=1&" & _
"submit1=Consultar"
Inet1.Execute "http://www.anses.gov.ar/servicios/IGTPC/Consulta.aspx",
"POST", data, "Content-Type: application/x-www-form-urlencoded"
'bucle que espera que el control inet este listo
Do While Ready1 = False
DoEvents
Loop
Ready1 = False
str = Inet1.GetChunk(100000, icString)
'salvo la página de links. El documento que puse en txtDoc devuelve
varios resultados en una pagina de links.
num = FreeFile
Open "f:\cuil\exp-multi.htm" For Output As num
Print #num, str
Close num
If InStr(1, str, "Para seleccionar un expediente, realice un doble
click") <> 0 Then
'Mas de 1 expediente
'javascript:__doPostBack('DGExp$_ctl2$_ctl0','')
j = 2
count = 0
Do While True
If InStr(1, str, "javascript:__doPostBack('DGExp$_ctl" & CStr(j)
& "$_ctl0','')") <> 0 Then
count = count + 1
j = j + 1
Else
'no hay mas
Exit Do
End If
Loop
Inet3 = Inet1
For j = 2 To count + 1
'str =
Inet1.OpenURL("javascript%3A%5F%5FdoPostBack%28%27DGExp%24%5Fctl" & CStr(j)
& "%24%5Fctl0%27%2C%27%27%29")
Inet1.Execute , "POST", "%5F%5FEVENTTARGET=DGExp%3A%5Fctl" &
CStr(j) & "%3A%5Fctl0&%5F%5FEVENTARGUMENT=%00", "Content-Type:
application/x-www-form-urlencoded"
Do While Ready1 = False
DoEvents
Loop
Ready1 = False
str = Inet1.GetChunk(100000, icString)
num = FreeFile
Open "f:\cuil\exp-multi" & CStr(j - 1) & ".htm" For Output As
num
Print #num, str
Close num
Inet1 = Inet3
Next
MsgBox "Ok. " & CStr(count) & " expedientes procesados."
Else
'1 expediente
num = FreeFile
Open "f:\cuil\exp.htm" For Output As num
Print #num, str
Close num
WebBrowser1.Visible = True
WebBrowser1.Silent = True
WebBrowser1.navigate "f:\cuil\exp.htm"
Do While WebBrowser1.Busy = True
DoEvents
Loop
Do While WebBrowser1.readyState <> READYSTATE_COMPLETE
DoEvents
Loop
WebBrowser1.document.Charset = "UTF-8"
WebBrowser1.Refresh
MsgBox "Ok"
End If
End Sub
Well, the thing is that the problem as I said results in clicking the links
that has the "URL" javascript:__doPostBack('DGExp$_ctl2$_ctl0','')
I have tested a lot of things, changing arguments, but is does not work (it
returns me the page WITHOUT the result data).
Apparently it does not submit the data as it has to.
Of course I will thank your answers very very much.
With attention,
Juan
My name is Juan. I am new to the forum.
Here I leave you a problem to see if you can help me.
General Description
I am developing an application in Visual Basic 6.
The program has to consult an ASP page of a public argentinian service
called ANSES, obtain a result from the response (the query is done by
completing a form).
The program sends the query with an Internet Transfer Control and the POST
method supported.
Up to here, all goes Ok.
The problem is that sometimes, the query result may not finish in the result
page, but the ASP server can respond as result a page with links. And
clicking on those links makes appear the final desired result.
So, my program detects if the response is effectively the final query result
or a link form to click inside. This does it Ok.
The problem is that I do not know to simulate a click on a corresponding
form link with Visual Basic code, or simulate the submit method from that
control with POST.
I have tried with many entry data but no way.
Details
Data form filling page:
http://www.anses.gov.ar/expedientes.htm
ASP page:
http://www.anses.gov.ar/servicios/IGTPC/Consulta.aspx
Visual Basic code to automate the query response:
Private Sub Command4_Click()
Dim str As String
Dim data As String
Dim bData() As Byte
Dim num As Long
Dim j As Long
Dim count As Long
'completa los datos del formulario de expedientes
data = "txtDoc=6903892&" & _
"TipoTramite=1&" & _
"submit1=Consultar"
Inet1.Execute "http://www.anses.gov.ar/servicios/IGTPC/Consulta.aspx",
"POST", data, "Content-Type: application/x-www-form-urlencoded"
'bucle que espera que el control inet este listo
Do While Ready1 = False
DoEvents
Loop
Ready1 = False
str = Inet1.GetChunk(100000, icString)
'salvo la página de links. El documento que puse en txtDoc devuelve
varios resultados en una pagina de links.
num = FreeFile
Open "f:\cuil\exp-multi.htm" For Output As num
Print #num, str
Close num
If InStr(1, str, "Para seleccionar un expediente, realice un doble
click") <> 0 Then
'Mas de 1 expediente
'javascript:__doPostBack('DGExp$_ctl2$_ctl0','')
j = 2
count = 0
Do While True
If InStr(1, str, "javascript:__doPostBack('DGExp$_ctl" & CStr(j)
& "$_ctl0','')") <> 0 Then
count = count + 1
j = j + 1
Else
'no hay mas
Exit Do
End If
Loop
Inet3 = Inet1
For j = 2 To count + 1
'str =
Inet1.OpenURL("javascript%3A%5F%5FdoPostBack%28%27DGExp%24%5Fctl" & CStr(j)
& "%24%5Fctl0%27%2C%27%27%29")
Inet1.Execute , "POST", "%5F%5FEVENTTARGET=DGExp%3A%5Fctl" &
CStr(j) & "%3A%5Fctl0&%5F%5FEVENTARGUMENT=%00", "Content-Type:
application/x-www-form-urlencoded"
Do While Ready1 = False
DoEvents
Loop
Ready1 = False
str = Inet1.GetChunk(100000, icString)
num = FreeFile
Open "f:\cuil\exp-multi" & CStr(j - 1) & ".htm" For Output As
num
Print #num, str
Close num
Inet1 = Inet3
Next
MsgBox "Ok. " & CStr(count) & " expedientes procesados."
Else
'1 expediente
num = FreeFile
Open "f:\cuil\exp.htm" For Output As num
Print #num, str
Close num
WebBrowser1.Visible = True
WebBrowser1.Silent = True
WebBrowser1.navigate "f:\cuil\exp.htm"
Do While WebBrowser1.Busy = True
DoEvents
Loop
Do While WebBrowser1.readyState <> READYSTATE_COMPLETE
DoEvents
Loop
WebBrowser1.document.Charset = "UTF-8"
WebBrowser1.Refresh
MsgBox "Ok"
End If
End Sub
Well, the thing is that the problem as I said results in clicking the links
that has the "URL" javascript:__doPostBack('DGExp$_ctl2$_ctl0','')
I have tested a lot of things, changing arguments, but is does not work (it
returns me the page WITHOUT the result data).
Apparently it does not submit the data as it has to.
Of course I will thank your answers very very much.
With attention,
Juan