Oliver Dewar
Board Regular
- Joined
- Apr 17, 2011
- Messages
- 201
Hi Guys.
I'm using the following code to work out if a link to a url is broken or not:
But sometimes it marks a link red (for broken) when in fact it's a redirect. I'm going to trap the 301 redirect statuses to handle those, however I sometimes encounter a status '0' and text 'Unknown' when there's a redirect (presumably a different kind to 301).
The only way I can come up with to programmatically test if a destination page of a '0' redirect is in fact OK or not is to find out what the destination url is then run keyword tests on it.
With that in mind I'd like to know how to return the destination url when using the above method (if possible).
I can achieve it with the:
method... but that involves reloading the url and would slow down the process a lot. It's a fall back... but if anyone knows a way to get the redirect destination from the original method I'd appreciate the tip
I'm using the following code to work out if a link to a url is broken or not:
Code:
strURL = Activecell.value 'this is the url to test
Set objhttp = CreateObject("MSXML2.XMLHTTP")
objhttp.Open "HEAD", strUrl, False
objhttp.send
If objhttp.statusText <> "OK" Then
Activecell.Interior.Color = 255
End If
But sometimes it marks a link red (for broken) when in fact it's a redirect. I'm going to trap the 301 redirect statuses to handle those, however I sometimes encounter a status '0' and text 'Unknown' when there's a redirect (presumably a different kind to 301).
The only way I can come up with to programmatically test if a destination page of a '0' redirect is in fact OK or not is to find out what the destination url is then run keyword tests on it.
With that in mind I'd like to know how to return the destination url when using the above method (if possible).
I can achieve it with the:
Code:
With IE
.Visible = False
.Navigate domain 'this is the url
msgbox .LocationURL
End With
method... but that involves reloading the url and would slow down the process a lot. It's a fall back... but if anyone knows a way to get the redirect destination from the original method I'd appreciate the tip
Last edited: