I’m scraping a website using VBA (from Access) and MSHTML (via IE 6), similar to covered on thread starting with post post 292415.
My question is: how do I tell what response code I received? How do I tell whether I got a 200 (OK) or 404 (Not found)? The actual page returned for those codes varies depending on the web server, but I should be able to get the HttpResponse code. My basic code is:
Dim objMSHTML As New MSHTML.HTMLDocument Dim objDocument As MSHTML.HTMLDocument 'This function is only available with Internet Explorer 5 and later Set objDocument = objMSHTML.createDocumentFromUrl(sURL, vbNullString) 'Tricky, to make the function wait for the document to complete, usually the 'transfer is asynchronous. Note that this string might be different if you have 'another language than English for Internet Explorer on the machine where the code is 'executed. While objDocument.readyState "complete" DoEvents Wend 'OK, now we've got the page If objDocument.Title = "404 Not Found" Then 'This is not a robust solution 'Need to get "objDocument.HttpResponseCode" or similar '...