Tuesday, March 13, 2012

Downloading a password protected file from a Web page using wget...

Today I was downloading some stuff from Web, and the download speeds were unbelievably slow (i.e. criminally slow)! The most I got was somewhere around few kilobytes per second. So, it's no wonder then that they lasted for a very long time, and some of them were reported as being finished, while actually only a part of the file was downloaded. To make things even more strange, ping reported RTT times that were within usual range of values when download speeds were much higher! Anyway, I didn't have a slightest clue what was happening. Usually, in those, cases, I use wget (or curl) to fetch a file, as they are more easily controlled and have much more features that the download mechanism embedded within Firefox. The problem was that, to access those files, I had to login and the login process isn't implemented using regular HTTP mechanism, but it's part of the Web application. Needless to say, wget (nor curl) don't know how to handle this situation.

The first thing that occurred to me is that wget supports loading of cookies from Firefox browser. So, I looked into wget manual page, and there it is an option --load-cookies. The only problem is that this option expect cookies to be stored in the old textual format, while Firefox starting from version 3 uses SQLite database. So, quick googling reveled several pages, of which I looked at this one. In short, that guy wrote a shell script that exports SQLite database into text file with a format expected by wget command. But reading comments, I found even better solution! It is a plugin called cliget. When you install this plugin it attaches itself to download dialog where it shows a wget command line you can use to download selected file from a terminal window. I tried it and it works great! So that solved my problems.

No comments:

About Me

scientist, consultant, security specialist, networking guy, system administrator, philosopher ;)

Blog Archive