vb_lover
May 22nd, 2010, 02:14 PM
I would like to autonomously access a web page, parse the document and do what I need to do with the collected data. The IE window will be invisible to the user therefore I need to detect any errors associated with a bad URL or a inaccessable page, etc..
For example: If I navigate to the page and encounter a 404 error, then I would not parse.
HOW DO I ACCOMPLISH THIS?? I can't find a property that would hold such HTTP status codes in the IE object.
'example code:
Dim IE as New InternetExplorer
Dim Doc as New HTMLDocument
IE.Navigate "www.myURL.com", navNoReadFromCache
'i will start a timer here and IE.STOP if things take too long
timer1.interval = 30000
timer1.enabled = true
Do Until IE.ReadyState = READYSTATE_COMPLETE
if userStopFlag = true then
IE.STOP
exit sub
endif
Loop
timer1.enabled = false
'HERE IS WHERE I WANT TO EXAMINE TO SEE IF I REALLY
'HAVE SOMETHING TO PARSE, MAYBE THE URL IS BAD OR
'WHATEVER, I WANT TO KNOW IF THERE ARE ANY ERRORS
'BEFORE I PARSE. Such as 503, 404, etc....
'If we get here then we can begin document processing.
For example: If I navigate to the page and encounter a 404 error, then I would not parse.
HOW DO I ACCOMPLISH THIS?? I can't find a property that would hold such HTTP status codes in the IE object.
'example code:
Dim IE as New InternetExplorer
Dim Doc as New HTMLDocument
IE.Navigate "www.myURL.com", navNoReadFromCache
'i will start a timer here and IE.STOP if things take too long
timer1.interval = 30000
timer1.enabled = true
Do Until IE.ReadyState = READYSTATE_COMPLETE
if userStopFlag = true then
IE.STOP
exit sub
endif
Loop
timer1.enabled = false
'HERE IS WHERE I WANT TO EXAMINE TO SEE IF I REALLY
'HAVE SOMETHING TO PARSE, MAYBE THE URL IS BAD OR
'WHATEVER, I WANT TO KNOW IF THERE ARE ANY ERRORS
'BEFORE I PARSE. Such as 503, 404, etc....
'If we get here then we can begin document processing.