<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://labs.echoditto.com" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>EchoDitto Labs - curl is awesome; Typepad is not - Comments</title>
 <link>http://labs.echoditto.com/typepad-and-curl</link>
 <description>Comments for &quot;curl is awesome; Typepad is not&quot;</description>
 <language>en</language>
<item>
 <title>curl is awesome; Typepad is not</title>
 <link>http://labs.echoditto.com/typepad-and-curl</link>
 <description>&lt;p&gt;Sometimes I wonder why I ever bothered to compile wget for OS X.  I keep finding clever new things that curl can do &amp;mdash; even some that make me wonder why I bother with Perl and Ruby&#039;s Mechanize module/gem.&lt;/p&gt;

&lt;p&gt;For instance: today I found myself needing to export a friend&#039;s Typepad blog.  He&#039;s got a lot of content, and I wanted to pull it down on a speedy connection and then gzip it before pulling it onto my laptop over my sluggish DSL (Typepad unhelpfully delivers its exported content in an uncompressed non-ML format).&lt;/p&gt;

&lt;p&gt;Typepad provides a URL for the export, but it only works when you&#039;ve authenticated through their website.  Curl makes working around this pretty simple, though, as I found out from &lt;a href=&quot;http://ask.metafilter.com/18923/How-do-you-handle-authentication-via-cookie-with-CURL&quot;&gt;this&lt;/a&gt; Ask Metafilter thread.  Here&#039;s how it works:&lt;/p&gt;

&lt;blockquote&gt;&lt;pre&gt;curl -k -d &quot;__mode=redir&amp;next=http://www.typepad.com/t/app&amp;username=user%27s+name&amp;password=their%20password&quot; -c cookie.txt https://www.typepad.com/t/app&lt;/pre&gt;&lt;/blockquote&gt;

&lt;p&gt;You simply use -k to turn off SSL requirements, -d to pass a series of key/value form pairs (properly url-encoded) to the URL to which the form posts, and -c to output the returned cookie to a file.&lt;/p&gt;

&lt;p&gt;Then you pass in the session-containing cookie file, allowing you to stay authenticated on subsequent requests:&lt;/p&gt;

&lt;blockquote&gt;&lt;pre&gt;curl -b cookie.txt -o complete-export.txt &quot;http://www.typepad.com/t/app/weblog/post?__mode=export&amp;blog_id=YOUR_BLOG_ID&quot;&lt;/pre&gt;&lt;/blockquote&gt;

&lt;p&gt;Naturally, you&#039;ll want to replace the URL in that last request with the one corresponding to your own export URL.&lt;/p&gt;

&lt;p&gt;It all worked perfectly &amp;mdash; well, up until the point at which I discovered that Typepad exports seem to inevitably fail once they top 100 megs.  Seriously guys: file compression.  Try it, you&#039;ll like it.&lt;/p&gt;</description>
 <comments>http://labs.echoditto.com/typepad-and-curl#comments</comments>
 <category domain="http://labs.echoditto.com/taxonomy/term/101">commandline</category>
 <category domain="http://labs.echoditto.com/taxonomy/term/98">curl</category>
 <category domain="http://labs.echoditto.com/taxonomy/term/5">scripting</category>
 <category domain="http://labs.echoditto.com/taxonomy/term/73">shell</category>
 <category domain="http://labs.echoditto.com/taxonomy/term/99">typepad</category>
 <category domain="http://labs.echoditto.com/taxonomy/term/100">unix</category>
 <pubDate>Wed, 10 Oct 2007 17:46:22 -0700</pubDate>
 <dc:creator>Tom</dc:creator>
 <guid isPermaLink="false">46 at http://labs.echoditto.com</guid>
</item>
</channel>
</rss>
