Jud*_*ngo 7 c# firefox favorites bookmarks
使用C#,我需要获取所有Firefox书签,以便将它们导入我们的数据库.我怎样才能做到这一点?
我知道这个问题,在Java中读取FF 3书签,但那里的答案似乎都围绕着Java数据库驱动程序,我不确定其中一些答案是不是特定于Java的.
我的主要问题是,"如何在C#中阅读Firefox书签?"
次要问题:我看到\%用户个人资料%\应用程序数据\ mozilla\firefox\profiles\bookmarkbackups\bookmarks- [date] .json文件 - 我可以解析一下吗?如果是这样,是否有任何现有的解析器?
修辞哀叹的问题:为什么这不能像IE一样简单,我只读了\%user profile%\ favorites中的.url文件?呸.
使用.Net的SQLite驱动程序并访问可在我的计算机上找到的文件places.sqlite
Application Data/Mozilla/Firefox/Profiles/$this_varies/places.sqlite
.您在目标计算机上找到它应该不难.
编辑1:
这是一段代码,用于打印数据库中的URL:
using System.Data.SQLite; // downloaded from http://sourceforge.net/projects/adodotnetsqlite
namespace sqlite_test
{
class Program
{
static void Main(string[] args)
{
var path_to_db = @"C:\places.sqlite"; // copied here to avoid long path
SQLiteConnection sqlite_connection = new SQLiteConnection("Data Source=" + path_to_db + ";Version=3;New=True;Compress=True;");
SQLiteCommand sqlite_command = sqlite_connection.CreateCommand();
sqlite_connection.Open();
sqlite_command.CommandText = "select * from moz_places";
SQLiteDataReader sqlite_datareader = sqlite_command.ExecuteReader();
while (sqlite_datareader.Read())
{
// Prints out the url field from the table:
System.Console.WriteLine(sqlite_datareader["url"]);
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
编辑2:
作为提示.我真的必须为firefox推荐SQLite Manager插件.它对于使用sqlite数据库非常有用.