讀取谷歌瀏覽器history 檔案

2022-09-06 13:39:25 字數 2995 閱讀 5998

chrome上網記錄提取小試——history - 知乎 (zhihu.com)

chrome歷史記錄分析 - 巨獸~墨菲特 - (cnblogs.com)

.這個檔案是sqllite格式

python 讀取sqllite

1

#-*- coding:utf8 -*-23

'''4

author:wang yanlong

5date: 2017-08-1667

8distributed under the bsd license.910

references:

11 (english)

12 (chinese)

13'''

1415

import

sqlite3 as db

1617

#從sqlite檔案中讀取資料

18def

readfronsqllite(db_path,exectcmd):

19 conn = db.connect(db_path) #

該 api 開啟乙個到 sqlite 資料庫檔案 database 的鏈結,如果資料庫成功開啟,則返回乙個連線物件

20 cursor=conn.cursor() #

該例程建立乙個 cursor,將在 python 資料庫程式設計中用到。

21 conn.row_factory=db.row #

可訪問列資訊

22 cursor.execute(exectcmd) #

該例程執行乙個 sql 語句

23 rows=cursor.fetchall() #

該例程獲取查詢結果集中所有(剩餘)的行,返回乙個列表。當沒有可用的行時,則返回乙個空的列表。

24return

rows25#

print(rows[0][2]) # 選擇某一列資料

2627

#解析arpa 單幀資訊

28def

29 subarpa=arpaframe.split(','

)30print

(subarpa)

3132

if__name__=="

__main__":

33 rows=readfronsqllite('

e:',"select arpa from arpainfo")

34 readlines=10010

35 lineindex=10000

36while lineindex37 row=rows[lineindex] #

獲取某一行的資料,型別是tuple

38 content="".join(row) #

tuple轉字串

解析arpa資料

40 lineindex+=1

————————————更新——————————————————————————

讀取**,同時包含轉換時間戳

1

import

sqlite3 as db

2import

time3#

從sqlite檔案中讀取資料

4def

readfronsqllite(db_path,exectcmd):

5 conn = db.connect(db_path) #

該 api 開啟乙個到 sqlite 資料庫檔案 database 的鏈結,如果資料庫成功開啟,則返回乙個連線物件

6 cursor=conn.cursor() #

該例程建立乙個 cursor,將在 python 資料庫程式設計中用到。

7 conn.row_factory=db.row #

可訪問列資訊

8 cursor.execute(exectcmd) #

該例程執行乙個 sql 語句

9 rows=cursor.fetchall() #

該例程獲取查詢結果集中所有(剩餘)的行,返回乙個列表。當沒有可用的行時,則返回乙個空的列表。

10return

rows11#

print(rows[0][2]) # 選擇某一列資料

1213

#解析arpa 單幀資訊

14def

15 subarpa=arpaframe.split(','

)16print

(subarpa)

1718

if__name__=="

__main__":

19 rows=readfronsqllite('

./data/history.db

',"select url,title,last_visit_time from urls ")

20print

(rows[0])

21 visite_time=rows[0][2]

22 true_time=visite_time/1000000-11644473600

23 time_normal = time.gmtime(true_time) #

轉換為普通時間格式(時間陣列)

24 dt = time.strftime("

%y-%m-%d %h:%m:%s

", time_normal) #

格式化為需要的格式

25print(f"")

26#27#

print(len(rows))28#

while lineindex29

#row=rows[lineindex] # 獲取某一行的資料,型別是tuple30#

content="".join(row) #tuple轉字串31#

32#lineindex+=1

谷歌瀏覽器

熬了這麼久終於想弄第二彈,謝謝大家對我第一彈的支援,但是這次的第二彈的豬腳我選擇的是新興的谷歌遊覽器chrome,這裡不把其他基於谷歌遊覽器核心的其他極速版遊覽器列入考慮,因為早在第一彈我已經預見國內ie核心的遊覽器肯定要出雙核,現在事實證明不斷跟上技術的變革才是王道,但是他們的更新沒有chrome...

關於瀏覽器的history

即history.replacestate 方法,這個方法接受三個引數,第乙個是狀態物件,第二個是頁面標題,第三個是頁面鏈結。具體 如下 if history.replacestate else history.replacestate 發放會替換當前頁面的瀏覽記錄,及頁面標題替換為 documen...

根據瀏覽器history模擬瀏覽器後退按鈕顯隱問題

措施 具體思路如下 1.開始開啟頁面時,瀏覽器的history.length為1,按鈕隱藏 2.當history.length 1時,點選按鈕執行 history.go 1 3.後退到歷史記錄棧中第一幀時,按鈕隱藏。出於瀏覽器安全性考慮,history中沒有給出屬性判斷其當前頁的位置,所以,在開始開...