문제

I have a long list of our company's product numbers, and later in the code these numbers have to be converted to HTML and then linked to the product's corresponding page. The links to the pages have numerous 301 redirects to get from something messy / old / mistyped / etc. to the new SEO friendly URLs.

For example, something like this:

site.com/12345

Will get redirected to this page:

site.com/product-name-12345

I do not have a list to compare the product names against, as they are created and destroyed daily, and the site creates the URL on the fly (rather than drawing from some kind of database or something).

For a lot of complicated reasons, I only have access to Excel to complete this task (hooray!). I've written (bad) code to open Internet Explorer, go to the short URL, and then copy the new address into whatever was needed. This works, but it's incredibly slow (as you might expect). I'm wondering if there is a solution that doesn't rely on waiting for IE to open, however runs exclusively in VBA?

I have found a lot of ways to see if the redirect takes place, and I have found a lot of ways to get the headers, however I have yet to find a way to get the final URL that occurs. These mostly focus on WinHTTP.WinHTTPRequest.5.1, however it seems as though there isn't any kind of WinHTTPResponse to call (like HttpResponse in .NET) supported by Excel.

Any help would be greatly appreciated, thanks!

EDIT: This was answered on another post to Reddit's Excel forum. The answer I needed was .Option(1) after the .Send (if anyone else needs it).

Discussion can be read here

도움이 되었습니까?

해결책

This was answered on another post to Reddit's Excel forum. The answer I needed was .Option(1) after the .Send (if anyone else needs it).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top