Programmatically acess Google chrome history

后端 未结 3 1126
情深已故
情深已故 2021-01-02 18:21

I want to index all the user actions and websites in google chrome. i understand that google chrome index all the data in sqlLite database. how can i Programmatically access

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-02 18:35

    In Windows form application with Datagridview tool - button click event

    private void button1_Click(object sender, EventArgs e)
        {
            string google = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Google\Chrome\User Data\Default\History";
            string fileName = DateTime.Now.Ticks.ToString();
            File.Copy(google, Application.StartupPath + "\\" + fileName);
            using (SQLiteConnection con = new SQLiteConnection("DataSource = " + Application.StartupPath + "\\" + fileName + ";Versio=3;New=False;Compress=True;"))
            {
                con.Open();
                //SQLiteDataAdapter da = new SQLiteDataAdapter("select url,title,visit_count,last_visit_time from urls order by last_visit_time desc", con);
                SQLiteDataAdapter da = new SQLiteDataAdapter("select * from urls order by last_visit_time desc", con);
                DataSet ds = new DataSet();
                da.Fill(ds);
                dataGridView1.DataSource = ds.Tables[0];
                con.Close();
            }
            try // File already open error is skipped
            {
              if (File.Exists(Application.StartupPath + "\\" + fileName))
                 File.Delete(Application.StartupPath + "\\" + fileName);
            }
            catch (Exception)
            {
            }
        }
    

    Reference source

    Here i have copied the History file to Application startup path in order to avoid SQLite error "database is locked".

提交回复
热议问题