views:

190

answers:

1

I'm using VBScript and the Microsoft.XMLHTTP object to scrape some web data. I have a list of URLs to check, but unfortunately some of them 301 redirect to others on the list, so I wind up with redundant data.

Is it at all possible to make the XMLHTTP object fail on 301 redirect? Or at least cache the original response header? Or otherwise just let me know what happened?

(notes: I have no control over the server I'm requesting data from; when I get new data, I could check if it's redundant, but I'd like to avoid that if possible).

Any ideas would be greatly appreciated.

+1  A: 

First, the ProgId you should be using is MSXML2.XMLHTTP.

The answer is, No - MSXML2.XMLHTTP automatically follows redirects.

If you need to track and optionally not follow redirects, then you can use the WinHttp.WinHttpRequest object, which, like MSXML2.XMLHTTP is accessible to script. In fact this is the object that MSXML2.XMLHTTP delegates to, for http loading.

You'll need to set the WinHttpRequestOptions to EnableRedirects.

See this Q&A on social.msdn.microsoft.com for more.

Cheeso
Great. Thanks for the input!
dmb