Capture the URL Redirect from searchquery and do final xpath

Hi to all,
i have many Products Code who i need fetch the photo from this website.

The problem is this, i need do 2 xpath

  1. is for fecth the final URL from search query.
    For exhample i have this products code: SFS1000

and i generate the link of query like this:

https://www.dbelectrical.com/search-results/?search_query_adv=SFS1000

The problem is this website, after searchquery redirect in another page, so the URL is not fixed and i cannot do the xpath of products image url.

So the question is: How i can fetch the final URL from this query?

https://www.dbelectrical.com/search-results/?search_query_adv=SFS1000

Thanks in advanced for help :blush:

This is trick because the redirect happens after the page is loaded and read by SeoTools. One solution, although complicated, is to use the Phantom Js Cloud API which identifies the redirect in the HTTP header "pjsc-content-url". Then you can use the HttpHeader function to get the redirect url:

I've masked the API key to Phantom JS but you can create your own formula using the Phantom JS Connector and supplying the original URL. Then, instead of doing a normal request, click "Debug:Debugger" and copy the URL sent from Seotools. This requires you to activate Debug mode first:

Finally, paste the URL and use the HttpHeader formula as shown in first image:
=HttpHeader(A1;"pjsc-content-name")

Making requests with Phantom Js is kind of slow because server side javascripts but it will get the job done. If you need to make many requests, you probably need a payed subscription.

1 Like

Hey Bro, I was expecting your solution. you are really smart! My compliments, and thanks for the help.