I’m developing a web browser in android environment, when i perform a search in google, and then i get google search results list. the url of these results is something like that :
this google url send me to the real page : http://www.test.com
Google uses that type of URL to track which links people click on. but, for me i need the real url, so is there a way to get the real url (http://www.test.com) from google redirect url (http://www.google.ca/url?sa=t&source=web&cd=1&ved=0CDUQFjAA&url=http%3A%2F%2Fww … )
I don’t want substring the url from the long string and make some replacements to get the real page url because, it’s not a reliable way to do it, since i will depend on google url structure, maybe they will change their parameters names in the future, so my method won’t work in this case …
So, i would like to know if there is a way to know What url has a redirect link sends me
thanks in advance.
If you look carefully, Google returns something like http://www.google.ca/url?xxx=…&yyy=…&url=real_url&zzz=… That is, the real URL is in the
urlGET parameter of the url returned by Google. All you need to do is parse the URL returned by google – the real URL will be in theurlGET parameter of the response. Don’t forget to do theurl_decodeon it.Another way of doing it is to take the full URL that google returns and do HTTP GET on it. You should receive a 301 or 302 redirect. From that response, read the value of
locationheader – this will be your real URL.