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 # establish the connection with # history database file which is # located at given location # you can search in your system # for that location and provide # the path here conn = sqlite3.connect("/path/to/History") # point out at the cursor c = conn.cursor() # create a variable id # and assign 0 initially id = 0 # create a variable result # initially as True, it will # be used to run while loop result = True # create a while loop and put # result as our condition while result: result = False # a list which is empty at first, # this is where all the urls will # be stored ids = [] # we will go through our database and # search for the given keyword for rows in c.execute("SELECT id,url FROM urls\ WHERE url LIKE '%geeksforgeeks%'"): # this is just to check all # the urls that are being deleted print(rows) # we are first selecting the id id = rows[0] # append in ids which was initially # empty with the id of the selected url ids.append((id,)) # execute many command which is delete # from urls (this is the table) # where id is ids (list having all the urls) c.executemany('DELETE from urls WHERE id = ?',ids) # commit the changes conn.commit() # close the connection conn.close() |
Output:
(16886, 'https://www.geeksforgeeks.org/')
Recommended Posts:
- Get Browser History using Python in Ubuntu
- Python | Launch a Web Browser using webbrowser module
- Browser Automation Using Selenium
- Python | Get a google map image of specified location using Google Static Maps API
- How to Delete files in Python using send2trash module?
- Python Program to delete a file
- Speech Recognition in Python using Google Speech API
- Performing Google Search using Python code
- Python | Plotting Google Map using gmplot package
- Python | Plotting Google Map using folium package
- Python | Plotting Data on Google Map using pygmaps package
- How to download Google Images using Python
- Python | Automate Google Search using Selenium
- Uploading files on Google Drive using Python
- Language Translator Using Google API in Python
- How to make a Google Translation API using Python?
- Audio processing using Pydub and Google speechRecognition API
- Outline specific area on Google Map using GeoJson
- Plotting ICMR approved test centers on Google Maps using folium package
- Python script to open a Google Map location on clipboard
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

