Permalink
Browse files

redirect.py added

  • Loading branch information...
1 parent 0419340 commit 3f51448da683cb9920d75247fd6f42175075b942 @jabbalaci committed Nov 16, 2011
Showing with 43 additions and 0 deletions.
  1. +6 −0 README
  2. +37 −0 redirect_to.py
View
6 README
@@ -6,6 +6,12 @@ Here I collect some small command-line utils.
Author: Laszlo Szathmary, 2011 (jabba.laci@gmail.com)
Github: https://github.com/jabbalaci/Bash-Utils
+
+redirect_to.py
+ Website: http://pythonadventures.wordpress.com/2010/12/21/where-does-a-page-redirect-to/
+ This script tells you where a webpage redirects.
+ Usage: ./redirect_to.py <URL>
+
mouse/mousepos_gui.py
Website: https://ubuntuincident.wordpress.com/2011/09/11/gui-to-monitor-mouse/
Monitor the mouse position in real-time.
View
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+
+"""
+Where does a URL redirect?
+==========================
+
+Author: Laszlo Szathmary, 2011 (jabba.laci@gmail.com)
+Website: http://pythonadventures.wordpress.com/2010/12/21/where-does-a-page-redirect-to/
+GitHub: https://github.com/jabbalaci/Bash-Utils
+
+This script tells you where a webpage redirects.
+
+Example:
+--------
+
+$ ./redirect_to.py http://bottlepy.org # calling the script
+http://bottlepy.org/docs/dev/ # output
+"""
+
+import sys
+import urllib
+
+
+def redirect(url):
+ try:
+ page = urllib.urlopen(url)
+ return page.geturl()
+ except:
+ print 'Error: there is something wrong with that URL'
+ sys.exit(1)
+
+
+if __name__ == "__main__":
+ if len(sys.argv) == 1:
+ print "Usage: {0} <url>".format(sys.argv[0])
+ else:
+ print redirect(sys.argv[1])

0 comments on commit 3f51448

Please sign in to comment.