Linux中Chrome浏览器的data存储在用户目录中的位置: ~/.config/google-chrome/Default/目录(其他请参考:http://www.chromium.org/user-experience/user-data-directory);HTML5本地存储(localstorage)中的条目位于Local\ Storage/的.localstorage文件;
developer@cwb-dev:~/.config/google-chrome/Default/Local Storage$ sqlite3 __0.localstorage
SQLite version 3.7.11 2012-03-20 11:35:50
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .database
seq name file
--- --------------- ----------------------------------------------------------
0 main /home/developer/.config/google-chrome/Default/Local Storag
sqlite> .table
ItemTable
sqlite> select * from ItemTable;
使用Perl存取Chrome Localstorage条目:
#! /usr/bin/perl
use DBI;
use strict;
my $homedir = $ENV{HOME};
$homedir ||= "/home/developer";
$dbh=DBI->connect("dbi:SQLite:dbname=$homedir/.config/google-chrome/Default/Local Storage/__0.localstorage","","",{RaiseError=>1,AutoCommit=>0});
my $sql = "SELECT * FROM ItemTable";
my $dbconn = $dbh->prepare($sql);
$dbconn->execute();
my (@row_ary,$c_key,$c_value);
while (@row_ary = $dbconn->fetchrow_array ){
my($c_key,$c_value) = @row_ary;
print "Items:\n";
print "\t@row_ary\n";
}
# my $sql = "update ItemTable set value='show'";
# $dbh->do( $sql );
# if ( $dbh->err() ) {
# die "$DBI::errstr\n";
# }
# $dbh->commit();
$dbh->disconnect();