wget is great for resuming downloads, something that no browser handles correctly. It has a very handy option, --load-cookie-file, which takes a cookies.txt style file from your browser and correctly serves it to the web server you’re connecting to. This is useful so you can download files where you have to log in first.
But of course, Safari doesn’t use the cookies.txt file format. Fortunately, Ruby and the plist gem come to the rescue.
$ sudo gem install plist
$ irb
>> require 'plist'
>> result = Plist::parse_xml("Library/Cookies/Cookies.plist")
>> File.open("cookies.txt", "w") {|f| result.each {|r| f.write("#{r["Domain"]}\tTRUE\t#{r["Path"]}\tFALSE\t#{r["Expires"].strftime("%s")}\t#{r["Name"]}\t#{r["Value"]}\n")}}
Dude. thanks. this saved my life.
I really didn’t feel like coding this myself today.
Awesome, exactly what i needed!
It’s so annoying that it’s simpler to just install Firefox and the Cookie Export plugin for the few sites that you need the cookies from. Apple, Google and Opera need to make it simpler.
Thanks for the script, though. It is useful and doesn’t make us install an entire program just to get this feature!
Thanks for this! I’m working on a Google Voice notifier and don’t need to write a login system now!