Home‎ > ‎

Export Google Reader Shared Items to Delicious Style HTML Bookmark File

posted Jul 4, 2010, 7:51 PM by Evan Blair Quirk   [ updated Jul 4, 2010, 8:30 PM ]
For the past year or so I've been using Google Reader Shared Items as my primary online bookmarking service, but recently I decided to make the switch to Google Bookmarks. Unfortunately there is little useful info on the export process from Google Reader. Here are the steps required to export your Google Reader Shared Items to a Delicious style html bookmark file, a much more useful format:

Step 1: Log into google services.


Step 3: Click on the "Atom Feed" link in the right column.

Step 4: Replace reading-list with broadcast?n=10000 to the end of the url of the new page that comes up, and resubmit.
(It should look like "http://www.google.com/reader/atom/user/03786026686106828213/state/com.google/broadcast?n=10000".)

Step 5: Take note of your google user number, in my case it is: 03786026686106828213.

Step : Download the result as google_reader.xml

Step : Download the script provided at the bottom as goog2html.pl in the same directory

Step 8: Edit goog2html.pl, change $usernum to your user number.

Step 7: Run the following command from the same directory as google_reader.xml and goog2html.pl:
           perl goog2html.pl > output.html

Voila! Now you have a Delicious style html bookmark file, which you can import to the service of your choice.

If you wish you make the switch to Google Bookmarks like I did, the easiest way I found is to first import this file into Delicious. Then use Mihai Parparita's delicious2google to import your bookmarks into Google Bookmarks.


goog2html.pl

#!/usr/bin/perl
use integer;

$file = "google_reader.xml";
$usernum = "03786026686106828213";

local $/=undef;
open FILE, $file or die "No such file.";
binmode FILE;
$content = <FILE>;
close FILE;

print <<HEAD;
<!DOCTYPE NETSCAPE-Bookmark-file-1> 
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"> 
<!-- This is an automatically generated file.
It will be read and overwritten.
Do Not Edit! --> 
<TITLE>Bookmarks</TITLE> 
<H1>Bookmarks</H1> 
<DL><p>
HEAD

@bookmarks = ($content =~ m#<entry.+?</entry>#sg);
foreach $bookmark (@bookmarks) {
  if($bookmark =~ m#gr:crawl-timestamp-msec="(.+?)"#s) {
    $time = $1;
    $time /= 1000;
  }

  if($bookmark =~ m#<title type="html">(.+?)</title>#s) {
    $title = $1;
  }

  if($bookmark =~ m#<link rel="alternate" href="(.+?)"#s) {
    $url = $1;
  }

  @labels = ($bookmark =~ m#term="user/$usernum/label/(.+?)"#g);
  $tags = join( ',', @labels );
  print '<DT><A HREF="'.$url.'" ADD_DATE="'.$time.'" PRIVATE="1" TAGS="'.$tags.'">'.$title."</A>\n";
}

print '</DL><p>';


Comments