Delete Google Browser History using Python
Last Updated :
16 Jul, 2020
In this article, you will learn to write a Python program which will take input from the user as a keyword like Facebook, amazon, geeksforgeeks, Flipkart, youtube, etc. and then search your google chrome browser history for that keyword and if the keyword is found in any of the URL then it will delete it. For example, suppose you have entered the keyword ‘geeksforgeeks’, so it will search your google chrome history, like ‘www.geekforgeeks.org’, it’s very obvious that this URL contains the keyword ‘geeksforgeeks’, then it will delete it, it will also search for articles (like “Is geeksforgeeks a good portal to prepare for competitive programming interview?”) containing ‘geeksforgeeks’ in their title and delete it. First of all, get the location in your system where the google chrome history file is located.
Note: Google chrome history file location in windows generally is: C:\Users\manishkc\AppData\Local\Google\Chrome\User Data\Default\History.
Implementation:
import sqlite3
conn = sqlite3.connect( "/path/to/History" )
c = conn.cursor()
id = 0
result = True
while result:
result = False
ids = []
for rows in c.execute("SELECT id ,url FROM urls\
WHERE url LIKE '%geeksforgeeks%' "):
print (rows)
id = rows[ 0 ]
ids.append(( id ,))
c.executemany( 'DELETE from urls WHERE id = ?' ,ids)
conn.commit()
conn.close()
|
Output:
(16886, 'https://www.geeksforgeeks.org/')
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...