Meniu

How to get the real URL behind a shortened URL using cURL

Now we will try to explain how to find the URL of a shortened URL, used on Twitter and other social networks, using cURL (Curl)

What is cURL?

Curl is a command line tool and a library that allows you to make a network request using the URL syntax, which supports more common protocols, such as http, https, ftp, etc. It is also freely available as a command line tool, so you can run it directly or from source code. It is also available for PHP.

Installation

If you are using a Debian-based GNU / Linux distribution, it can be installed using the following command as root:

# apt-get install curl

Testing

To do this, type the tracking command on your terminal and you will get the real address of the short URL:

$ curl -sLI http: // shortened_url | grep -i Location

The "s" option says that the loop should be silent, so it will not print the "download" progress, the "L" option says that it must follow all the redirects and download only the HTTP header, that is, everything we need. Finally, we use grep to get a header line that has a redirect URL.

John Doe

Articole publicate de la contributori ce nu detin un cont pe gnulinux.ro. Continutul este verificat sumar, iar raspunderea apartine contributorilor.
  • | 340 articole

Nici un comentariu inca. Fii primul!
  • powered by Verysign