Skip to content

Instantly share code, notes, and snippets.

@iceydee
Created October 5, 2011 06:33
Show Gist options
  • Save iceydee/1263789 to your computer and use it in GitHub Desktop.
Save iceydee/1263789 to your computer and use it in GitHub Desktop.
A simple script to convert Safari Cookies.plist to cookies.txt format. This is a minor rewrite from the script found here: http://seriousorange.com/2010/01/converting-safari-cookies-plist-to-cookies-txt/
#!/usr/bin/env ruby
require 'plist'
result = Plist::parse_xml(File.expand_path("~/Library/Cookies/Cookies.plist"))
result.each do |r|
arr = []
arr += [r["Domain"], "TRUE"]
arr += [r["Path"], "FALSE"]
arr << r["Expires"].strftime("%s")
arr += [r["Name"], r["Value"]]
line = arr.join("\t")
puts line
end
@iceydee
Copy link
Author

iceydee commented Oct 5, 2011

Note! Safari 5.1 (on OSX Lion) doesn't use Cookies.plist anymore but instead uses Cookies.binarycookies. I've created a simple command line tool which can export those into cookies.txt. You can find it here: https://github.com/talkative/exportCookies

@chrisndeca
Copy link

Hi there, I copy the ruby code above and saved into a text file with the extension of .rb and then I went to the terminal and ran the script and it gave me the following error:
`require': no such file to load -- plist (LoadError)
I have the plist gem installed (I was trying to follow the earlier version of this script.
If I enter in the lines of the script from "require" down to "puts" a ton of text gets outputted, but I am not sure if that is the correct format for a cookies.txt file.
Any ideas on what I am doing wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment