Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

How do you programmatically expand a url link to its true location?

How do you programmatically expand a url link to its true location?

How do you programmatically expand a url link to its true location?

How do you programmatically expand a url link to its true location?

Do you know about tinyurl.com and baidu.com? Baidu.com is a search engine that tries to discourage people from using their web site to make metasearch engines by hiding their links in a way that is a lot like how tinyurl.com works. TinyUrl.com is a web site where, if you want to present someone with a link to something and that link is long, you can use tinyurl to produce a tiny url for presentation purposes.

Anyway, what I want to do is to find a way to programmatically take the link http://www.baidu.com/link?url=mW91GJqjJ4zBBpC8yDF8... (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.

RE: How do you programmatically expand a url link to its true location?

Looks to me like baidu is encrypting the actual url, passing it around as a querystring parameter and decrypting as required. You'd have to know how they're encrypting/decrypting the url to get it back out of the querysting and I doubt they're going to share that with you unfortunately.


"Technological progress is like an axe in the hands of a pathological criminal"
"Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe"
Albert Einstein

RE: How do you programmatically expand a url link to its true location?

These url services just redirect from the shorter/encrypted url to the actual url. Open up Fiddler and watch what happens.
A GET is sent to http://www.baidu.com/link?url=mW91GJqjJ4zBBpC8yDF8..., which is returned with a status of 302 (which means redirect to) and there's a header called "Location" that says where to redirect to.


HTTP/1.1 302 Found
Connection: Keep-Alive
Proxy-Connection: Keep-Alive
Content-Length: 222
Expires: Fri, 30 Nov 2012 17:06:41 GMT
Date: Thu, 29 Nov 2012 17:06:41 GMT
Location: http://baike.baidu.com/view/270790.htm
Content-Type: text/html; charset=iso-8859-1
Server: Apache
Cache-Control: max-age=86400 

The browser will then ask for http://baike.baidu.com/view/270790.htm as it has been told to.

You can use the WebRequest object pretend to be a browser, make the request and read the headers back from it. You don't need to follow the link, if you don't want to.



Ben O'Hara

Quote (David W. Fenton)

We could be confused in exactly the same way, but confusion might be like Nulls, and not comparable.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close