This forum is in archive mode. You will not be able to post new content.

Author Topic: [Python] uNoShortURL, expand shortened URLs  (Read 813 times)

0 Members and 1 Guest are viewing this topic.

Offline daxda

  • Peasant
  • *
  • Posts: 114
  • Cookies: 112
  • Not the guy you're looking for
    • View Profile
    • Daxda on Github
[Python] uNoShortURL, expand shortened URLs
« on: March 29, 2014, 08:24:44 PM »
uNoShortURL
I've been working on this script for a few days now, I'm not quite happy about it just yet, but the moment will come.
So what does this script do you may ask, it extracts the destination URL of an URL shortened link,
for instance: http://bit.ly/1i09fqW will become https://evilzone.org

So far there are about 866 domains in the database which are supported, more will be added when I feel motivated
again to work on this project.

The script accepts either one or more URLs via the -u/--url parameter (seperated by space or comma) as well as reading
URLs from file. For the moment the script doesn't print the URLs to stdout, it prints it to stderr, feel free to modify your
version in any way you ever want.

 The usage information of this script:
Code: [Select]
usage: unshort.py [-h] [-q] (-u [URL [URL ...]] | -f FILE)

optional arguments:
  -h, --help            show this help message and exit
  -q, --quiet           Quiet mode, be as non-verbose as possible
  -u [URL [URL ...]], --url [URL [URL ...]]
                        One or more shortened URLs.
  -f FILE, --file FILE  Read URLs from file.


The requirements for this project:

Contribution:
If you feel like contributing check out le repo and help me gather test URLs which aren't already in the SERVICES file.


Feedback:
As always I'm trying to improve my code and at the same time my knowledge about python in general, if you have any
feedback, requests, improvements or bug reports please let me know!

And remember, this is a work in progress project, it might break your computer and detonate the c4 which was strapped
on your chest while you were reading this thread.

Download:
https://github.com/Daxda/uNoShortURL
« Last Edit: April 23, 2014, 08:11:25 PM by daxda »

Offline Kulverstukas

  • Administrator
  • Zeus
  • *
  • Posts: 6627
  • Cookies: 542
  • Fascist dictator
    • View Profile
    • My blog
Re: [Python] uNoShortURL, expand shortened URLs
« Reply #1 on: March 29, 2014, 08:46:59 PM »
866 domains? why do you keep a domain database? that seems dumb. Why not visit the link and read the redirection header to extract where it redirects you?

Offline daxda

  • Peasant
  • *
  • Posts: 114
  • Cookies: 112
  • Not the guy you're looking for
    • View Profile
    • Daxda on Github
Re: [Python] uNoShortURL, expand shortened URLs
« Reply #2 on: March 29, 2014, 09:10:05 PM »
Not all services use this kind of redirection there are multiple ways it can redirect you, but the way you suggested is used most of the time in my script.

 



Want to be here? Contact Ande, Factionwars or Kulverstukas on the forum or at IRC.