gpt4 book ai didi

python 3.4 谷歌浏览器历史

转载 作者:行者123 更新时间:2023-12-01 04:40:33 25 4
gpt4 key购买 nike

我真的被我想做的事情困住了。我想制作一个非常简单的脚本来显示 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 中数据库。 Python 通过 sqlite3 开箱即用地支持此功能。从 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))

关于python 3.4 谷歌浏览器历史,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30777897/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com