NEWS

[C#] Hướng dẫn xem lịch sử các trang web đã truy cập trên Chrome Browser

[C#] Hướng dẫn xem lịch sử các trang web đã truy cập trên Chrome Browser
Đăng bởi: Thảo Meo - Lượt xem: 4827 15:55:31, 17/03/2021DEVEXPRESS   In bài viết

Xin chào các bạn, bài viết hôm nay mình sẽ tiếp tục hướng dẫn các bạn cách cách xem lịch sử bạn đã mở các trang web trên trình duyệt Google Chrome C#.

[C#] View History and Search Keyword Chrome Browser

Trong bài viết trước, mình đã có hướng dẫn các bạn các xem mật khẩu được lưu trữ trên các trình duyệt web.

Bài này, mình sẽ nói về lịch sử truy cập website Google Chrome C#.

File History này sẽ lưu trữ những thông tin sau:

  1. Lịch sử các đường dẫn website bạn đã truy cập.
  2. Các từ khóa bạn tìm kiếm
  3. Lịch sử tải dữ liệu download của bạn.
  4. Đếm số lần truy cập website...

history_chrome_view

Tập tin History này là tập tin Sqlite, các bạn có thể sử dụng chương trình đọc cơ sở dữ liệu SQLite lên để xem.

Ở dưới mình sử dụng Navicate ở xem.

Lưu ý: Để mở được file các bạn cần tắt trình duyệt Chrome rồi mới xem được nhé.

google_history_csharp

Vì vậy công việc giờ các bạn muốn xem thông tin thì chỉ cần dùng C# để đọc dữ liệu lên là xong.

Các bạn cũng có thể xóa dữ liệu lịch sử Chrome này bằng code của mình một cách dễ dàng phải không nào.

Giao diện demo ứng dụng xem lịch sử trình duyệt Chrome c#:

view_history_chrome

Full source code View History Chrome Browser C#:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SQLite;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace HistoryChrome
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnGetHistory_Click(object sender, EventArgs e)
        {
            List<HistoryItem> allHistoryItems;
            string chromeHistoryFile = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
        + @"\Google\Chrome\User Data\Default\History";
            if (File.Exists(chromeHistoryFile))
            {
                SQLiteConnection connection = new SQLiteConnection
                ("Data Source=" + chromeHistoryFile + ";Version=3;New=False;Compress=True;");
                connection.Open();
                DataSet dataset = new DataSet();
                SQLiteDataAdapter adapter = new SQLiteDataAdapter
                ("select * from urls order by last_visit_time desc", connection);
                adapter.Fill(dataset);
                if (dataset != null && dataset.Tables.Count > 0 & dataset.Tables[0] != null)
                {
                    DataTable dt = dataset.Tables[0];
                    allHistoryItems = new List<HistoryItem>();
                    foreach (DataRow historyRow in dt.Rows)
                    {
                        HistoryItem historyItem = new HistoryItem()
                        {
                            URL = Convert.ToString(historyRow["url"]),
                            Title = Convert.ToString(historyRow["title"])
                        };

                        long utcMicroSeconds = Convert.ToInt64(historyRow["last_visit_time"]);

                        DateTime gmtTime = DateTime.FromFileTimeUtc(10 * utcMicroSeconds);

                        DateTime localTime = TimeZoneInfo.ConvertTimeFromUtc(gmtTime, TimeZoneInfo.Local);

                        historyItem.VisitedTime = localTime;
                        allHistoryItems.Add(historyItem);
                    }
                    dataGridView1.DataSource = allHistoryItems;
                }
            }
        }
    }

    public class HistoryItem
    {
        public string URL { get; set; }
        public string Title { get; set; }
        public DateTime VisitedTime { get; set; }
    }
}

Thanks for watching!

DOWNLOAD SOURCE

THÔNG TIN TÁC GIẢ

BÀI VIẾT LIÊN QUAN

[C#] Hướng dẫn xem lịch sử các trang web đã truy cập trên Chrome Browser
Đăng bởi: Thảo Meo - Lượt xem: 4827 15:55:31, 17/03/2021DEVEXPRESS   In bài viết

CÁC BÀI CÙNG CHỦ ĐỀ

Đọc tiếp
.