I've got a spreadsheet with about 7000 rows of data. I have a URL for each row, but the URL is entered as a search query that redirects to the appropriate result:
URL-LINK - www.shopcwi.com/searchresults.aspx?SearchTerm=A1032

When following this URL, it immediately redirects you to the item URL:

This is the URL I need to use for the =IMPORTXML function, but I really don't want to copy the redirect URLs one by one 7000 times. Is there an easy way, formula, script, w/e to pull the URL that the search query URL redirects to?

I've tried searching every variation of this question I can think of with no success. I'm at a total loss. I know enough about scripting to modify things to suit my needs usually, but I can't find a starting point, and I'm not knowledgeable enough to do it from scratch. I'm hoping there's some easy solution like a formula, or perhaps an external URL redirect checker (which I've also been trying to search for) where you can upload a list of URLs and it will export a list of destination URLs.

New contributor
Cannonball James is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • Welcome. Please add a brief description of your search/research efforts as is suggested in How to Ask. – Rubén Mar 26 at 18:21
  • Edited. Not much to add, as I'm at a total loss on this. I've been searching all morning and thus far, nada. – Cannonball James Mar 26 at 18:34
  • AFAIK there aren't built-in functions you might try to use / learn about the Google Apps Script Url Fetch service. Since that is more about programming than using Google Sheets / Google Apps Script web editor, I suggest you to look for questions about getting redirect urls in Stack Overflow. Good luck. – Rubén Mar 26 at 18:39
  • Well shoot... can't post there for 90 minutes. – Cannonball James Mar 26 at 18:51
  • Have you looked at How to return a redirected URL in Google Sheets on StackOverflow. – Tedinoz Mar 27 at 11:08

Your Answer

Cannonball James is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.