python3—-读取本机谷歌浏览器的访问的URL历史记录信息
1、本机谷歌浏览器的历史记录信息:
在该目录下:C:\Users\Administrator\AppData\Local\Google\Chrome\User Data\Default
2、谷歌浏览器的历史记录使用的sqlite3数据库存储数据的:
使用sqlite3数据浏览工具查看如下
3、读取URL的历史记录信息,python3脚本代码:
# -*- coding: utf-8 -*-
"""
Created on Fri Jun 22 20:00:02 2018
@author: Administrator
"""
import os
import sqlite3
import operator
from collections import OrderedDict
if __name__ == '__main__':
#指到用户的谷歌浏览器的历史记录
data_path = r'C:\Users\Administrator\AppData\Local\Google\Chrome\User Data\Default'
files = os.listdir(data_path)
history_db = os.path.join(data_path,'history1')
#查询数据库内容
conn = sqlite3.connect(history_db)
cursor = conn.cursor()
select_statement_queryall = 'SELECT * FROM urls;'
#select_statement_query = 'SELECT urls.url,urls.visit_count FROM urls,visits WHERE urls.id=visits.url;'
#select_statement_delete_id = ' DELETE FROM urls;'
#cursor.execute(select_statement_delete_id)
#conn.commit#修改数据必须commit提交下
cursor.execute(select_statement_queryall)
results = cursor.fetchall()
for d in results:
print("ID: "+str(d[0])+'\t'+"URL: "+str(d[1])+"\t"+"Title: "+str(d[2])+'\t'+"visit_count: "+str(d[3])+'\t'+"typed_count: "+str(d[4])+'\t'+"last_visit_time: "+str(d[5])+'\t'+"hiddlen: "+str(d[6])+