Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you programmatically find a true URL in C# instead of a forwarding link?

Tags:

c#

url

Another way to ask this question is this: How do you programmatically expand a TinyURL link to its true location?

What I want to do is to find a way to programmatically take the link:

http://www.baidu.com/link?url=mW91GJqjJ4zBBpC8yDF8xDhiqDSn1JZjFWsHhEoSNd85PkV8Xil7qccoOX3rynaE

(the first link in a search for Jessica Alba using baidu.com) and have it return the actual link:

http://baike.baidu.com/view/270790.htm

That is just one example. What I want to do is not specific to Jessica but for using Baidu.com as part of my group of search engines in my meta search engine project.

Maybe there is a way of using the WebBrowser class but I did not see a member that was the URL.

Maybe there is a way of using WebRequest and WebResponse.

like image 321
xarzu Avatar asked Nov 28 '12 07:11

xarzu


Video Answer


1 Answers

Make a request to tinied URL, and parse out the HTTP response Location header.

like image 179
Amadan Avatar answered Sep 30 '22 19:09

Amadan