<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mithro rants about stuff &#187; firefox</title>
	<atom:link href="http://blog.mithis.net/archives/tag/firefox/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.mithis.net</link>
	<description></description>
	<lastBuildDate>Fri, 16 Dec 2011 06:02:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Reading cookies from most Firefox versions&#8230;</title>
		<link>http://blog.mithis.net/archives/python/94-reading-cookies-firefox</link>
		<comments>http://blog.mithis.net/archives/python/94-reading-cookies-firefox#comments</comments>
		<pubDate>Mon, 19 Jan 2009 23:59:49 +0000</pubDate>
		<dc:creator>mithro</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[cookies]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[snippet]]></category>

		<guid isPermaLink="false">http://blog.mithis.net/?p=94</guid>
		<description><![CDATA[Yesterday, I wrote about how to reading the cookies from Firefox 3.0 from Python. This code snippet extends the previous example by adding code which finds the cookie file on various different operating systems (Windows, Linux and Mac OS X). Hope this helps people who need to do this. #! /usr/bin/env python # Reading the [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday, I wrote about how to reading the <a href="http://blog.mithis.net/archives/python/90-firefox3-cookies-in-python">cookies from Firefox 3.0</a> from Python. This code snippet extends the previous example by adding code which finds the cookie file on various different operating systems (Windows, Linux and Mac OS X). Hope this helps people who need to do this.</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#! /usr/bin/env python</span>
<span style="color: #808080; font-style: italic;"># Reading the cookie's from Firefox/Mozilla. Supports Firefox 3.0 and Firefox 2.x</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;"># Author: Noah Fontes &lt;nfontes AT cynigram DOT com&gt;, </span>
<span style="color: #808080; font-style: italic;">#         Tim Ansell &lt;mithro AT mithis DOT com&gt;</span>
<span style="color: #808080; font-style: italic;"># License: MIT</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> sqlite2cookie<span style="color: black;">&#40;</span>filename<span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">cStringIO</span> <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">StringIO</span>
    <span style="color: #ff7700;font-weight:bold;">from</span> pysqlite2 <span style="color: #ff7700;font-weight:bold;">import</span> dbapi2 <span style="color: #ff7700;font-weight:bold;">as</span> sqlite
&nbsp;
    con = sqlite.<span style="color: black;">connect</span><span style="color: black;">&#40;</span>filename<span style="color: black;">&#41;</span>
&nbsp;
    cur = con.<span style="color: black;">cursor</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    cur.<span style="color: black;">execute</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;select host, path, isSecure, expiry, name, value from moz_cookies&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
    ftstr = <span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;FALSE&quot;</span>,<span style="color: #483d8b;">&quot;TRUE&quot;</span><span style="color: black;">&#93;</span>
&nbsp;
    s = <span style="color: #dc143c;">StringIO</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    s.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;&quot;&quot;<span style="color: #000099; font-weight: bold;">\</span>
# Netscape HTTP Cookie File
# http://www.netscape.com/newsref/std/cookie_spec.html
# This is a generated file!  Do not edit.
&quot;&quot;&quot;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">for</span> item <span style="color: #ff7700;font-weight:bold;">in</span> cur.<span style="color: black;">fetchall</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
        s.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;%s<span style="color: #000099; font-weight: bold;">\t</span>%s<span style="color: #000099; font-weight: bold;">\t</span>%s<span style="color: #000099; font-weight: bold;">\t</span>%s<span style="color: #000099; font-weight: bold;">\t</span>%s<span style="color: #000099; font-weight: bold;">\t</span>%s<span style="color: #000099; font-weight: bold;">\t</span>%s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>
            item<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>, ftstr<span style="color: black;">&#91;</span>item<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>.<span style="color: black;">startswith</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'.'</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span>, item<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>,
            ftstr<span style="color: black;">&#91;</span>item<span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span>, item<span style="color: black;">&#91;</span><span style="color: #ff4500;">3</span><span style="color: black;">&#93;</span>, item<span style="color: black;">&#91;</span><span style="color: #ff4500;">4</span><span style="color: black;">&#93;</span>, item<span style="color: black;">&#91;</span><span style="color: #ff4500;">5</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
    s.<span style="color: black;">seek</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span>
&nbsp;
    cookie_jar = <span style="color: #dc143c;">cookielib</span>.<span style="color: black;">MozillaCookieJar</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    cookie_jar._really_load<span style="color: black;">&#40;</span>s, <span style="color: #483d8b;">''</span>, <span style="color: #008000;">True</span>, <span style="color: #008000;">True</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> cookie_jar
&nbsp;
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">cookielib</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">os</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">logging</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">ConfigParser</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># Set up cookie jar paths</span>
<span style="color: #ff7700;font-weight:bold;">def</span> _get_firefox_cookie_jar <span style="color: black;">&#40;</span>path<span style="color: black;">&#41;</span>:
    profiles_ini = <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>path, <span style="color: #483d8b;">'profiles.ini'</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">exists</span><span style="color: black;">&#40;</span>path<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">or</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">exists</span><span style="color: black;">&#40;</span>profiles_ini<span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">None</span>
&nbsp;
    <span style="color: #808080; font-style: italic;"># Open profiles.ini and read the path for the first profile</span>
    profiles_ini_reader = <span style="color: #dc143c;">ConfigParser</span>.<span style="color: #dc143c;">ConfigParser</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">;</span>
    profiles_ini_reader.<span style="color: black;">readfp</span><span style="color: black;">&#40;</span><span style="color: #008000;">open</span><span style="color: black;">&#40;</span>profiles_ini<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
    profile_name = profiles_ini_reader.<span style="color: black;">get</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'Profile0'</span>, <span style="color: #483d8b;">'Path'</span>, <span style="color: #008000;">True</span><span style="color: black;">&#41;</span>
&nbsp;
    profile_path = <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>path, profile_name<span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">exists</span><span style="color: black;">&#40;</span>profile_path<span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">None</span>
    <span style="color: #ff7700;font-weight:bold;">else</span>:
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>profile_path, <span style="color: #483d8b;">'cookies.sqlite'</span><span style="color: black;">&#41;</span>:
            <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>profile_path, <span style="color: #483d8b;">'cookies.sqlite'</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">elif</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>profile_path, <span style="color: #483d8b;">'cookies.txt'</span><span style="color: black;">&#41;</span>:
            <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>profile_path, <span style="color: #483d8b;">'cookies.txt'</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> _get_firefox_nt_cookie_jar <span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
    <span style="color: #808080; font-style: italic;"># See http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/473846</span>
    <span style="color: #ff7700;font-weight:bold;">try</span>:
        <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">_winreg</span>
        <span style="color: #ff7700;font-weight:bold;">import</span> win32api
    <span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #008000;">ImportError</span>:
        <span style="color: #dc143c;">logging</span>.<span style="color: black;">error</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'Cannot load winreg -- running windows and win32api loaded?'</span><span style="color: black;">&#41;</span>
    key = <span style="color: #dc143c;">_winreg</span>.<span style="color: black;">OpenKey</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">_winreg</span>.<span style="color: black;">HKEY_CURRENT_USER</span>, r<span style="color: #483d8b;">'Software<span style="color: #000099; font-weight: bold;">\M</span>icrosoft<span style="color: #000099; font-weight: bold;">\W</span>indows<span style="color: #000099; font-weight: bold;">\C</span>urrentVersion<span style="color: #000099; font-weight: bold;">\E</span>xplorer<span style="color: #000099; font-weight: bold;">\S</span>hell Folders'</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">try</span>:
        result = <span style="color: #dc143c;">_winreg</span>.<span style="color: black;">QueryValueEx</span><span style="color: black;">&#40;</span>key, <span style="color: #483d8b;">'AppData'</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #008000;">WindowsError</span>:
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">None</span>
    <span style="color: #ff7700;font-weight:bold;">else</span>:
        key.<span style="color: black;">Close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> ret<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span> == <span style="color: #dc143c;">_winreg</span>.<span style="color: black;">REG_EXPAND_SZ</span>:
            result = win32api.<span style="color: black;">ExpandEnvironmentStrings</span><span style="color: black;">&#40;</span>ret<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">else</span>:
            result = ret<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">return</span> _get_firefox_cookie_jar<span style="color: black;">&#40;</span><span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>result, r<span style="color: #483d8b;">'Mozilla<span style="color: #000099; font-weight: bold;">\F</span>irefox<span style="color: #000099; font-weight: bold;">\P</span>rofiles'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> _get_firefox_posix_cookie_jar <span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">return</span> _get_firefox_cookie_jar<span style="color: black;">&#40;</span><span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">expanduser</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">'~/.mozilla/firefox'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> _get_firefox_mac_cookie_jar <span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
    <span style="color: #808080; font-style: italic;"># First of all...</span>
    result = _get_firefox_cookie_jar<span style="color: black;">&#40;</span><span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">expanduser</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">'~/Library/Mozilla/Firefox/Profiles'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">if</span> result == <span style="color: #008000;">None</span>:
        result = _get_firefox_cookie_jar<span style="color: black;">&#40;</span><span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">expanduser</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">'~/Library/Application Support/Firefox/Profiles'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> result
&nbsp;
FIREFOX_COOKIE_JARS = <span style="color: black;">&#123;</span>
    <span style="color: #483d8b;">'nt'</span>: _get_firefox_nt_cookie_jar,
    <span style="color: #483d8b;">'posix'</span>: _get_firefox_posix_cookie_jar,
    <span style="color: #483d8b;">'mac'</span>: _get_firefox_mac_cookie_jar
<span style="color: black;">&#125;</span>
&nbsp;
cookie_jar = <span style="color: #008000;">None</span>
<span style="color: #ff7700;font-weight:bold;">try</span>:
    cookie_jar = FIREFOX_COOKIE_JARS<span style="color: black;">&#91;</span><span style="color: #dc143c;">os</span>.<span style="color: black;">name</span><span style="color: black;">&#93;</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #008000;">KeyError</span>:
    cookie_jar = <span style="color: #008000;">None</span>
&nbsp;
path = <span style="color: #008000;">raw_input</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'Path to cookie jar file [%s]: '</span> <span style="color: #66cc66;">%</span> cookie_jar<span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">if</span> path.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
    <span style="color: #808080; font-style: italic;"># Some input specified, set it</span>
    cookie_jar = <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">realpath</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">expanduser</span><span style="color: black;">&#40;</span>path.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> cookie_jar.<span style="color: black;">endswith</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'.sqlite'</span><span style="color: black;">&#41;</span>:
    cookie_jar = sqlite2cookie<span style="color: black;">&#40;</span>cookie_jar<span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">else</span>:
    cookie_jar = <span style="color: #dc143c;">cookielib</span>.<span style="color: black;">MozillaCookieJar</span><span style="color: black;">&#40;</span>cookie_jar<span style="color: black;">&#41;</span></pre></div></div>

</blockquote>
<p><i>Edit: The latest version of this code can be found at <a href="http://blog.mithis.com/cgi-bin/gitweb.cgi">http://blog.mithis.com/cgi-bin/gitweb.cgi</a> and includes numerous fixes and updates.</i></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mithis.net/archives/python/94-reading-cookies-firefox/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Reading Firefox 3.x cookies in Python</title>
		<link>http://blog.mithis.net/archives/python/90-firefox3-cookies-in-python</link>
		<comments>http://blog.mithis.net/archives/python/90-firefox3-cookies-in-python#comments</comments>
		<pubDate>Mon, 19 Jan 2009 03:28:28 +0000</pubDate>
		<dc:creator>mithro</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[cookie jar]]></category>
		<category><![CDATA[cookies]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[sqlite]]></category>

		<guid isPermaLink="false">http://blog.mithis.net/?p=90</guid>
		<description><![CDATA[I found the following code snippet on my hard drive today. It allows you to access Firefox 3.x cookies in Python. Firefox 3.x moved away from the older text file format to a sqlite database. This code is useful if you want to access something behind an authentication gateway and you also access the page [...]]]></description>
			<content:encoded><![CDATA[<p>I found the following code snippet on my hard drive today. It allows you to access <a href="http://www.getfirefox.com" target="_self">Firefox 3.x</a> cookies in Python. Firefox 3.x moved away from the older text file format to a <a href="http://www.sqlite.org/">sqlite</a> database.</p>
<p>This code is useful if you want to access something behind an authentication gateway and you also access the page through your web browser. You can also use this code to convert a sqlite database into a cookie file <a href="http://curl.haxx.se/">CURL</a> can read.</p>
<p>I didn&#8217;t write this code, it was written by Noah Fontes when we where doing some scraping of the <a href="http://code.google.com/soc">Google Summer of Code</a> website (before I joined Google).</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#! /usr/bin/env python</span>
<span style="color: #808080; font-style: italic;"># Protocol implementation for handling gsocmentors.com transactions</span>
<span style="color: #808080; font-style: italic;"># Author: Noah Fontes nfontes AT cynigram DOT com</span>
<span style="color: #808080; font-style: italic;"># License: MIT</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> sqlite2cookie<span style="color: black;">&#40;</span>filename<span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">cStringIO</span> <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">StringIO</span>
    <span style="color: #ff7700;font-weight:bold;">from</span> pysqlite2 <span style="color: #ff7700;font-weight:bold;">import</span> dbapi2 <span style="color: #ff7700;font-weight:bold;">as</span> sqlite
&nbsp;
    con = sqlite.<span style="color: black;">connect</span><span style="color: black;">&#40;</span>filename<span style="color: black;">&#41;</span>
&nbsp;
    cur = con.<span style="color: black;">cursor</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    cur.<span style="color: black;">execute</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;select host, path, isSecure, expiry, name, value from moz_cookies&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
    ftstr = <span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;FALSE&quot;</span>,<span style="color: #483d8b;">&quot;TRUE&quot;</span><span style="color: black;">&#93;</span>
&nbsp;
    s = <span style="color: #dc143c;">StringIO</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    s.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;&quot;&quot;<span style="color: #000099; font-weight: bold;">\</span>
# Netscape HTTP Cookie File
# http://www.netscape.com/newsref/std/cookie_spec.html
# This is a generated file!  Do not edit.
&quot;&quot;&quot;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">for</span> item <span style="color: #ff7700;font-weight:bold;">in</span> cur.<span style="color: black;">fetchall</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
        s.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;%s<span style="color: #000099; font-weight: bold;">\t</span>%s<span style="color: #000099; font-weight: bold;">\t</span>%s<span style="color: #000099; font-weight: bold;">\t</span>%s<span style="color: #000099; font-weight: bold;">\t</span>%s<span style="color: #000099; font-weight: bold;">\t</span>%s<span style="color: #000099; font-weight: bold;">\t</span>%s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>
            item<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>, ftstr<span style="color: black;">&#91;</span>item<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>.<span style="color: black;">startswith</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'.'</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span>, item<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>,
            ftstr<span style="color: black;">&#91;</span>item<span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span>, item<span style="color: black;">&#91;</span><span style="color: #ff4500;">3</span><span style="color: black;">&#93;</span>, item<span style="color: black;">&#91;</span><span style="color: #ff4500;">4</span><span style="color: black;">&#93;</span>, item<span style="color: black;">&#91;</span><span style="color: #ff4500;">5</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
    s.<span style="color: black;">seek</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span>
&nbsp;
    cookie_jar = <span style="color: #dc143c;">cookielib</span>.<span style="color: black;">MozillaCookieJar</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    cookie_jar._really_load<span style="color: black;">&#40;</span>s, <span style="color: #483d8b;">''</span>, <span style="color: #008000;">True</span>, <span style="color: #008000;">True</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> cookie_jar</pre></div></div>

</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.mithis.net/archives/python/90-firefox3-cookies-in-python/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Quotidian!</title>
		<link>http://blog.mithis.net/archives/uncategorized/77-epiphany2firefox</link>
		<comments>http://blog.mithis.net/archives/uncategorized/77-epiphany2firefox#comments</comments>
		<pubDate>Thu, 10 Apr 2008 00:34:50 +0000</pubDate>
		<dc:creator>mithro</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[epiphany]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://blog.mithis.net/archives/uncategorized/77-epiphany2firefox</guid>
		<description><![CDATA[I&#8217;m sure most people are wondering what he hell &#8220;quotidian&#8221; is, I myself did not know this word existed. The word actually means mundane or everyday, a work colleague suggested it when I asked is anyone knew what the opposite to epiphany was. So you probably wondering why I&#8217;m going on about some stupid word, [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m sure most people are wondering what he hell &#8220;<a href="http://dictionary.reference.com/search?q=Quotidian&amp;x=0&amp;y=0">quotidian</a>&#8221; is, I myself did not know this word existed.  The word actually means mundane or everyday, a work colleague suggested it when I asked is anyone knew what the opposite to epiphany was. So you probably wondering why I&#8217;m going on about some stupid word, well the reason is that I have finally converted from the gnome <a href="http://live.gnome.org/Epiphany">Epiphany</a> web browser to <a href="http://www.mozilla.com/en-US/firefox/">Firefox</a>.</p>
<p>For thoses who don&#8217;t know, Epiphany is generally described as &#8220;the closest thing to Gnome&#8217;s official web browser&#8221;. It has lots of nifty features and use to have much better intergration with the Gnome desktop (things like actually using the Gnome print dialog). I use to advocate that Gnome should push Epiphany instead of Firefox.</p>
<p>So why have I given up? <span style="font-weight: bold">I&#8217;m tired of my browser being broken</span>.</p>
<p>The developers of Epiphany decided to make some huge changes in the latest version, they started adding support for the <a href="http://webkit.org/">WebKit</a> (the render behind Safari) instead of just being dependent on <a href="http://en.wikipedia.org/wiki/Gecko_(layout_engine)">Gecko</a> (the same render Firefox uses). This is actually a very good goal, being able to have a choice of renders in my browser would be great. However, in the process of doing this change they broke everything! Things like the vitally important Adblock extension no longer work and the password manager is totally broken in a number of ways &#8211; for a long time they didn&#8217;t even show up in the dialog.</p>
<p>I&#8217;m okay with a few bugs here and there (even these quite serious ones) to get something better in the long run. I have diligently reported bugs as I found them (even firing up a different browser when the gnome bug browser was crashing Epiphany). I even started porting Google Gears to Epiphany because I had faith that Epiphany was going to remain a killer browser.</p>
<p>Now I find out that it has all been for nothing, the developers have decided they are going to totally ditch Gecko and move only to WebKit (with all the compatibility problems it will bring). There are so many reasons why this is a bad idea, none of which I&#8217;m going to repeat here.</p>
<p>So I&#8217;m now writing this in Firefox instead of Epiphany and I&#8217;m pretty happy. Having access to all the extensions that Firefox has is really nice for once. There a number of features which I miss from Epiphany and extensions have filled most of that void, so what did I install?</p>
<ul>
<li><a href="http://www.penguinus.com/dev/tab_history/">Tab History</a>, this means that new tabs have the same history as the parent tab. This is something Epiphany does by default and I find absolutely vital.</li>
<li><a href="https://addons.mozilla.org/en-US/firefox/addon/4550">Compact Menu 2</a>, a little extension which gives you the ability to have all your menus in a single button saving you precious vertical screen space.</li>
<li><a href="http://adblockplus.org/en/">Ad Block Plus</a>, got to keep away those evil ads. It&#8217;s amazing how annoying the web is with ads, I had gotten so use to not seeing them that I didn&#8217;t know how bad it actually was.</li>
<li><a href="http://noscript.net/">NoScript</a>, get rid of all that annoying flash and evil javascript. In epiphany I generally ended up just apt-get removing flash, now I can still watch stupid Youtube videos without being violated by monkies.</li>
</ul>
<p>I also installed two extensions that have no equivalent under Epiphany, they are</p>
<ul>
<li><a href="https://addons.mozilla.org/en-US/firefox/addon/748">Greasemonkey</a>, the extension for making websites the way you like them.</li>
<li><a href="http://www.getfirebug.com/">Firebug</a>, a really cool tool for figuring out how a website is made up and various problems with them.</li>
</ul>
<p>I&#8217;m still looking for an extension which makes the Firefox 3.0 URL bar sane. I really like how the Epiphany one behaves and will probably end up writing my own extension if I don&#8217;t find anything. The important features that I require are,</p>
<ul>
<li>Single line per URL with the title on the right.</li>
<li>Support for &#8220;smart bookmarks&#8221; as the last option. These let you search for the current term at Google or Wikipedia without prefixing it with a stupid keyword or something.</li>
</ul>
<p>Here is what my Firefox looks like currently. As you can see I have significantly customized the toolbar to remove all that excesses.</p>
<p style="text-align: center"><a href="http://blog.mithis.net/wp-content/uploads/2008/04/myfirefox.png" title="Screenshot of my Firefox"><img src="http://blog.mithis.net/wp-content/uploads/2008/04/myfirefox.png" alt="Screenshot of my Firefox" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mithis.net/archives/uncategorized/77-epiphany2firefox/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

