使用Python分析谷歌浏览器Chrome的网页浏览历史记录
来源:互联网 发布:舞霸王跳舞软件 编辑:程序博客网 时间:2024/05/17 18:25
1.代码示例如下:
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)效果展示:
备注:主要用到sqlite和使用第三方python包matplotlib绘图
参考资料来源于:
<<使用Python分析谷歌浏览器Chrome的历史记录>>
http://mp.weixin.qq.com/s?src=3×tamp=1461695187&ver=1&signature=wnZn1UtWreFWjQbpWweZXp6RRvmmKwW1-Kud3x6OF0fyEUbGoUrfVJkdthk7m33uuO9xMwJhkqhA*Pyih0SCe2VZ2WBo--lqw20BbuZ57E07qwQHjCPUoX5eYgn*5zSAKIQfR3hHefsU2zdYvxWy7vm-Duq7m32TIKMl0y6eFA8=
0 0
- 使用Python分析谷歌浏览器Chrome的网页浏览历史记录
- 使用Python分析谷歌浏览器Chrome的历史记录
- python分析谷歌浏览器的历史记录
- 使用Python获取Chrome浏览器历史记录
- chrome 浏览器浏览网页(html)乱码
- 清除Chrome浏览器的历史记录、缓存
- 用Chrome和firefox浏览器模拟手机浏览器浏览网页
- android 对浏览器书签、浏览历史记录的数据添加
- 谷歌浏览器chrome的使用
- Google Chrome(谷歌浏览器)浏览GOOGLE崩溃的解决方法
- Google Chrome 浏览器历史记录的获取与清除
- 关于谷歌Chrome浏览器设置退出时自动清除历史记录等
- 使用chrome浏览器查看当前网页的http头 信息
- 使用chrome浏览器查看当前网页的http头
- 使用chrome浏览器查看当前网页的http头
- 浏览器history对象关于历史记录的使用
- 对于谷歌浏览器(chrome)容易上瘾的分析
- chrome 浏览器的缩略图怎么没有了?就是浏览过网页的缩略图,一点击就能打开网站。
- LeetCode 252. Meeting Rooms
- ERROR 1045 (28000): Access denied for user root@localhost (using password: YES)
- Android地面站-MavLink解析部分源码
- LeetCode 171. Excel Sheet Column Number
- Runtime基本使用
- 使用Python分析谷歌浏览器Chrome的网页浏览历史记录
- 【机器学习】Data Scientist进阶书籍
- 制作右下角箭头的.9图片
- nfs
- CSS选择器
- MVC生成CheckBoxList并对其验证
- php简简单单搞定中英文混排字符串截取,只需2行代码!
- html中的meta详解
- .Net开源网络爬虫Abot介绍