使用Python分析谷歌浏览器Chrome的历史记录
来源:互联网 发布:球球大作战java源代码 编辑:程序博客网 时间:2024/05/17 18:27
先安装包matplotlib
pip install matplotlib
整篇的代码片
import osimport sqlite3import operatorfrom collections import OrderedDictimport matplotlib.pyplot as pltdef parse(url): try: parsed_url_components = url.split('//') sublevel_split = parsed_url_components[1].split('/', 1) domain = sublevel_split[0].replace("www.", "") return domain except IndexError: print "URL format error!"def analyze(results): prompt = raw_input("[.] Type <c> to print or <p> to plot\n[>] ") if prompt == "c": for site, count in sites_count_sorted.items(): print site, count elif prompt == "p": plt.bar(range(len(results)), results.values(), align='edge') plt.xticks(rotation=45) plt.xticks(range(len(results)), results.keys()) plt.show() else: print "[.] Uh?" quit()#path to user's history database (Chrome)data_path = os.path.expanduser('~')+"\AppData\Local\Google\Chrome\User Data\Default"files = os.listdir(data_path)history_db = os.path.join(data_path, 'history')#querying the dbc = sqlite3.connect(history_db)cursor = c.cursor()select_statement = "SELECT urls.url, urls.visit_count FROM urls, visits WHERE urls.id = visits.url;"cursor.execute(select_statement)results = cursor.fetchall() #tuplesites_count = {} #dict makes iterations easier :Dfor url, count in results: url = parse(url) if url in sites_count: sites_count[url] += 1 else: sites_count[url] = 1sites_count_sorted = OrderedDict(sorted(sites_count.items(), key=operator.itemgetter(1), reverse=True))analyze (sites_count_sorted)
实现的效果
a、统计图
b、数据的统计
参考地址:http://mp.weixin.qq.com/s?__biz=MjM5NzU0MzU0Nw==&mid=2651370207&idx=1&sn=0edfb3ea20f1eefe06bd910bf2e9018a&mpshare=1&scene=24&srcid=1117HhAxrzIaIieGgQEmif8T#rd
0 0
- 使用Python分析谷歌浏览器Chrome的历史记录
- 使用Python分析谷歌浏览器Chrome的网页浏览历史记录
- python分析谷歌浏览器的历史记录
- 使用Python获取Chrome浏览器历史记录
- 清除Chrome浏览器的历史记录、缓存
- 谷歌浏览器chrome的使用
- Google Chrome 浏览器历史记录的获取与清除
- 关于谷歌Chrome浏览器设置退出时自动清除历史记录等
- 浏览器history对象关于历史记录的使用
- 对于谷歌浏览器(chrome)容易上瘾的分析
- 谷歌浏览器chrome的使用技巧视频(英文)
- 谷歌浏览器chrome使用的几点技巧
- 工具的使用——谷歌浏览器(chrome)
- 操纵浏览器的历史记录
- Chrome浏览器使用的快捷键
- Chrome 谷歌浏览器
- Chrome谷歌浏览器的快捷键:
- 绿色版的谷歌浏览器chrome
- [game]《泰坦陨落2》
- 利用CATextLayer渲染文本
- JSON(二)Gson的使用
- nginx的gzip压缩功能参数介绍(ngx_http_gzip_module)
- hive 三种启动方式及用途
- 使用Python分析谷歌浏览器Chrome的历史记录
- android中的内部存储与外部存储
- 【Qt开发】 QT:make: Nothing to be done for `first'和error:QtSql:No such file or directory
- 2016年下半年规划
- FIFO管道写规则
- Fedora安装Hadoop
- 作业七-ID-1052-Problem D: Sequence Problem (III) : Array Practice
- 零基础PS----制作动态图片GIF
- HTTPS 互联网世界的安全基础