![](/img/trans.png)
[英]Python - How I can find the timestamp of visited URL from sqlite History file of Google Chrome history?
[英]How can i change chrome history with sqlite3 python?
这是我的代码
import sqlite3
conn = sqlite3.connect("path to chrome history")
c = conn.cursor()
c.executemany("UPDATE urls SET url = REPLACE(url,.foo.,.foo-bar.) WHERE url LIKE %foo%;")
conn.close()
它抛出以下错误:
c.executemany("UPDATE urls SET url = REPLACE(url,.foo.,.foo-bar.) WHERE url LIKE %foo%;")
TypeError: executemany expected 2 arguments, got 1
如何在 Python 中使用 sqlite3 更改 Google Chrome 中的历史记录?
午饭后我有时间看这个,这就是我蹒跚而行的。 使用风险自负(在运行之前备份“历史”文件)。
import sqlite3
conn = sqlite3.connect(r"path to chrome history")
c = conn.cursor()
for url in c.execute("SELECT * FROM urls WHERE url LIKE '%foo%'"):
# Execute returns a tuple. Need to convert to list to edit.
# Then convert back to tuple for use in f-string
url = list(url)
url[1] = url[1].replace("foo", "foo-bar") # String replace
url = tuple(url)
c.execute(f"REPLACE INTO urls VALUES {url}")
c.close()
conn.commit()
conn.close()
注意:Chrome 必须关闭才能运行,否则文件将被锁定。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.