[personal profile] tara_hanoi
Cross-posted to [community profile] command_liners

I'm a fan of twitter, and one of the features of the territory is shortened links. The twitter web interface generally does a half-decent job of expanding these posts, but I don't always get to see the expanded link.

Sometimes I want to see where the link leads without actually visiting the site in case it's hosting malicious scripts. After a little bit of digging I found that wget can do exactly what I want. I have a little throwaway directory (in my case, '/export/home/sketchy', which allows me to see where the link points to.

For example, let's say I see a link (it leads to a blog post of mine, so nothing very interesting) and want to know where it leads:

tara_hanoi@tara_babel:/export/home/sketchy$ wget --max-redirect=0 http://t.co/8xED8dz
--2011-07-25 16:01:10-- http://t.co/8xED8dz
Resolving t.co... 199.59.148.12
Connecting to t.co|199.59.148.12|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://bit.ly/guxtdh [following]

0 redirections exceeded.


The bit in bold is where you should be paying attention. In this case, the t.co link points to another shortener, bit.ly - if I want to follow that on, I don't have to paste that back into wget, I can just increase the 'max-redirect' parameter:

tara_hanoi@tara_babel:/export/home/sketchy$ wget --max-redirect=1 http://t.co/8xED8dz
--2011-07-25 16:03:50-- http://t.co/8xED8dz
Resolving t.co... 199.59.148.12
Connecting to t.co|199.59.148.12|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://bit.ly/guxtdh [following]
--2011-07-25 16:03:51-- http://bit.ly/guxtdh
Resolving bit.ly... 168.143.172.53, 2001:418:e801::12:1, 2001:418:e801::15:1, ...
Connecting to bit.ly|168.143.172.53|:80... connected.
HTTP request sent, awaiting response... 301 Moved
Location: http://tara-hanoi.dreamwidth.org/1508.html [following]

1 redirections exceeded.


Ok, so it leads to my own DW entry, so I'm pretty sure it's ok.

This might be useful for folks as a quick and dirty way to expand shortened URLs.

Date: 2011-07-25 03:34 pm (UTC)
chebe: (Default)
From: [personal profile] chebe
Thanks for the great post! And for showing me this trick. It's great for looking before you leap. I've an example here of a shortened url that I was sent over twitter that I used this on. Check out all the really suspicious ... stuff;
(*Do not click these links!*)

$ wget --max-redirect=2 bit.ly/qhgQzg
--2011-07-14 12:00:33-- http://bit.ly/qhgQzg
Resolving bit.ly... 168.143.172.53, 2001:418:e801::10:1, 2001:418:e801::11:1, ...
Connecting to bit.ly|168.143.172.53|:80... connected.
HTTP request sent, awaiting response... 301 Moved
Location: http://ad1595namq-s9qlvxp3wwbwn7w.hop.clickbank.net/?tid=KN [following]
--2011-07-14 12:00:35-- http://ad1595namq-s9qlvxp3wwbwn7w.hop.clickbank.net/?tid=KN
Resolving ad1595namq-s9qlvxp3wwbwn7w.hop.clickbank.net... 96.47.69.60, 96.47.69.61
Connecting to ad1595namq-s9qlvxp3wwbwn7w.hop.clickbank.net|96.47.69.60|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://ad1595namq-s9qlvxp3wwbwn7w.hop.clickbank.net/hop/?CBRehoppp2=http%3A%2F%2Fwww.zygorguides.com%3Fhop%3Dcamaro62v8&hstr=1310641234319%7Ccamaro62v8.kn%7C%7Cl6hfep4vgq%7Cwowzygor&code=%7B14%7D&key=C197C90A&parms=&s=default&ds=0 [following]
--2011-07-14 12:00:36-- http://ad1595namq-s9qlvxp3wwbwn7w.hop.clickbank.net/hop/?CBRehoppp2=http%3A%2F%2Fwww.zygorguides.com%3Fhop%3Dcamaro62v8&hstr=1310641234319%7Ccamaro62v8.kn%7C%7Cl6hfep4vgq%7Cwowzygor&code=%7B14%7D&key=C197C90A&parms=&s=default&ds=0
Reusing existing connection to ad1595namq-s9qlvxp3wwbwn7w.hop.clickbank.net:80.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://www.zygorguides.com?hop=camaro62v8 [following]
2 redirections exceeded.

Profile

tara_hanoi

September 2015

S M T W T F S
   12345
6789101112
13141516171819
20212223242526
27282930   

Most Popular Tags

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 21st, 2017 06:47 am
Powered by Dreamwidth Studios