I'm Marnanel, and this is my blog. Well, sort of. It isn't timely like a blog, and I don't expect you to subscribe to the feed (though I won't complain if you do). Rather, treat it as a quick trot around my mind, a chat over a pint in the pub, assuming you'd be caught dead talking about software in the pub. You should start here.

Sunday, June 03, 2007

wget for protected files

wget is a hugely useful program. You give it a URL and it goes and fetches it and saves it to disk. There's a ton of other options (spider a whole site, pretend to be a different browser, fetch all the URLs in a list in a file, delay fetches a certain or random number of seconds, etc) but that's the basic idea.

Anyway, I just needed to retrieve a file which was protected. It was a phone post on a friend's LiveJournal, which was friends-locked-- so, if you simply attempt to wget the URL you get a "forbidden" error, because it doesn't know who you are. Assuming you use Firefox, and you're logged into LJ, this is how to tell it:

wget --load-cookies ~/.mozilla/firefox/some-weird-string.default/cookies.txt http://username.livejournal.com/data/phonepost/xyz.ogg

some-weird-string will be different for everyone, but always the same for you. ls ~/.mozilla/firefox to find out what it is.

I was amused that this resulted in a redirection to a URL ending ...Thanks+for+ signing+in+ /+LiveJournal+loves+you +a+lot+/ +Here+have+a+cookie.

1 comments:

Anonymous said...

If I remember correctly, that haiku actually has a purpose. It's copyrightable, which the rest of the URL and cookie aren't, so if anyone steals anyone else's cookies, copyright law comes into play!