Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting information from Internet Explorer

Status
Not open for further replies.

techinvt

Programmer
May 9, 2007
19
0
0
US
Is there any way to retrieve information from a web page? I am working on a program that submits information to a web site and that part works fine. But after I submit the information the web site responds by bringing me to a NEW page that displays a message that basically says "OK, the information you sent us is correct - now go to this url to retrieve it" - I need a way for the program to check the content on the page to make sure it says "the info you sent us is correct" and to get the redirect URL so it can continue.

Thanks!
 
That's what ASP is designed to do. You might get a closer look at it.
 
I looked, but ASP seems to be a server side thing to dynamically construct web pages - unless I completely missed something, this will not help get get information from the web page on the user side?
 

Try the Inet control

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
Also worth taking a look at the XMLHTTP components, they can be used to submit data to a webservice via GET or POST and retrieve the result.

Take a look at the code I posted in at the bottom of this thread; it is used to submit some form data and then check for both a HTTP 200 status and an "OK" response from the webservice. You could quite easily modify that code to fit your needs.

 
nimroduk -
Is that code VB6 or VB .net? If VB6, and specific modules or anything have to be installed / called?

Thanks
 
Its for VB6 m8.

You need to reference the "Microsoft XML, v3.0" (or newer) library (C:\Windows\System32\MSXML3.dll).

 
>Is that code VB6 or VB .net?

You're in the VB5/6 forum, so the liklihood is that you'll get VB5/6 answers ...
 
Nimroduk:

Thanks!

Strongm:

Well ya, I figured that, but somewhere in the back of my head I had the idea stuck that you could not work with XML with VB6 - don't ask me why. So like I always tell my students - 'Better to ask the question and have people think you are stupid then not ask the question and prove it' lol
 
Though I generally avoid the technique, a lot of people will use an IE WebBrowser control for this. Probably the best argument for doing this is that IE is pretty good at parsing imperfect HTML.

I used to prefer using one of the MSXML implementations of the XMLHTTPRequest object. There are basically two of these, and in most cases you'll actually want to use the fuller-featured ServerXMLHTTPRequest in a VB6 program.

I gave up on using any of the XMLHTTPRequest classes in most VB6 programs. The biggest headache is that unless you can get by with using them in dumb (synchronous) mode they're frustrating. The event model they expose is not designed to work with VB6, it follows the JavaScript model instead. This means using XMLHTTPRequest and ServerXMLHTTPRequest asynchronously is very messy in VB, though not impossible.

Alternatives include:
[ul][li]The Internet Transfer control ("Inet"),[/li]
[li]A UserControl designed to exploit the AsyncRead method,[/li]
[li]Some third party HTTP control, or[/li]
[li]An HTTP UserControl based on the Winsock control or Winsock API.[/li][/ul]

If the data involved is XML I'd still use the MSMXL library for its DOM class and parser/serializer logic. If the data is HTML though MSXML is relatively worthless.

For HTML you'll either want to look at that WebBrowser control or else write your own logic to parse the HTML. This may not be too bad at all - if you can get away with tailoring it closely to a very few specific pages. In many cases a few clever Split() operations are all you need to pull out one or two important items.
 
This thread thread708-970319 might provide some ideas as well.
 
OK, so I'm starting to get a handle on this and I'm working my way through some XML tutorials (having a hard time finding them that deal with VB6 not .net - maybe that's why I got the idea it would not work with VB6). Now for the BIG favor - As I have worked VERY little with .net and not at all with XML, can someone look at this sample code I was given and kind of translate it into VB6 terms that I will have an easier time understanding? I've done a lot of programming with VB6 but there are just some things here I've never worked with, and as I said earlier - better to ask...

I have the format for a file that I have to create that I asume is what is referenced in the "localhost" line (I'll put my comments in where I think I might understand or have questions). Below I have posted the typical "reply" from the server containing the info for the redirect...

Private _rc As XmlHttpResult
Private Sub Send(ByVal XmlStream As String)

Dim url As String = "Dim oHttp As MSXML2.XMLHTTP = New MSXML2.XMLHTTP
oHttp.open("POST", url, False)
oHttp.setRequestHeader("Content-Type", "application/x-oHttp.send(XmlStream)
Me.txtResult.Text = oHttp.responseText & vbCrLf

So - here's what I kind of need translated to VB6 (the end result I need is to be able to create this in VBA so I don't have to write and call an entire .net program)


Private _rc As XmlHttpResult
Private Sub Send(ByVal XmlStream As String)

*************************************************
HERE - I assume this references the file I have to create to submit? But I'm not sure how this is pointing to the file?
*************************************************

Dim url As String = "Dim oHttp As MSXML2.XMLHTTP = New MSXML2.XMLHTTP
oHttp.open("POST", url, False)
oHttp.setRequestHeader("Content-Type", "application/x-oHttp.send(XmlStream)
Me.txtResult.Text = oHttp.responseText & vbCrLf

_rc = DotNet.Functions.Data.XmlDeserialize(oHttp.responseText, GetType(XmlHttpResult), False)

System.Diagnostics.Process.Start(_rc.RedirectUrl)
oHttp = Nothing


End Sub

Public Class XmlHttpResult

Private _Status As Integer
Private _ErrorMessage As String
Private _RedirectUrl As String
Private _DataGuid As String

Public Sub New()
End Sub

Public Property Status() As Integer
Get
Return _Status
End Get
Set(ByVal Value As Integer)
_Status = Value
End Set
End Property

Public Property ErrorMessage() As String
Get
Return _ErrorMessage
End Get
Set(ByVal Value As String)
_ErrorMessage = Value
End Set
End Property

Public Property RedirectUrl() As String
Get
Return _RedirectUrl
End Get
Set(ByVal Value As String)
_RedirectUrl = Value
End Set
End Property

Public Property DataGuid() As String
Get
Return _DataGuid
End Get
Set(ByVal Value As String)
_DataGuid = Value
End Set
End Property
End Class



<?xml version="1.0" encoding="utf-16"?>
<XmlHttpResult xmlns:xsd=" xmlns:xsi=" <Status>0</Status>
<ErrorMessage />
<RedirectUrl> <DataGuid>003d3e2e-1add-4b8e-8882-29d5ed3fb24c</DataGuid>
</XmlHttpResult>
 
I wouldn't go about things the way you are. Unfortunately, the code you're posting has a number of classes that are part of the .Net Framework, and as such are completely incompatible with VB6. It's not just a matter of translating syntax, it's a matter of not using the classes that are being instantiated and finding other ways to do what you want.

So, let me ask you this: web pages that use asp end in .asp. Have you ever seen an asp page ask for input from the web page? If so, what does it do with it? Nothing? Perhaps you really ARE completely missing something? :)

Perhaps you'd like to take a closer look at ASP. In particular, you might want to have a look at the request and response objects. Also, is a good source for all things ASP, as is the forum here.

HTH

Bob
 
Well, thanks to everyone for all the help - I was able to cobble together a working program with lots of research and info I gleamed from the replies here.
 
errr.... "gleaned" that is. 1/2 my vb errors come from fumble fingers lol
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top