python 3.4 谷歌浏览器历史

2024-01-04

我真的被我想做的事情困住了。 我想制作一个非常简单的脚本来显示 Google Chrome 的历史记录。 当我使用以下代码行时:

f = open('C:\\Users\\joey\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\History', 'rb')
data = f.read()
f.close()

我得到下一个输出,我只会显示一部分,因为否则它会太长。

x00\x00\x00\x00\x00\x81#\x9cU\n\x00\x81yC\t\x08\x06\x08\x08https://www.google.nl/search?q=de+zigodoom&oq=de+zigodoom&aqs=chrome..69i57.1507j0j7&sourceid=chrome&es_sm=93&ie=UTF-8de zigodoom

我怎样才能只显示网站而不显示所有 x00/x000 输出。我怎样才能在不同的行上显示每个网站。

for d in data:
print(data)

像这样简单的 for 循环可以工作吗?


Google Chrome 浏览器的历史记录存储在SQLite https://www.sqlite.org/数据库。 Python 通过以下方式提供了开箱即用的支持sqlite3 https://docs.python.org/2/library/sqlite3.html从Python 2.5开始。

import sqlite3
con = sqlite3.connect('C:\\Users\\joey\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\History')
cursor = con.cursor()
cursor.execute("SELECT url FROM urls")
urls = cursor.fetchall()
print('\n'.join(urls))
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

python 3.4 谷歌浏览器历史 的相关文章

随机推荐