Python: getting all addresses from every open Google Chrome tab

I need to get all urls from all open Google Chrome tabs in python 3 without intuition from the user. Im on Windows 10 using Microsoft Visual Studio Python3

Ive tried:

Opening it directly with the open one (the path to the current tabs) - does not work, because I do not have permission - I think it is blocked because chrome is actively writing to it.

Current_Tabs_Source = open(r"C:\Users\Beni\AppData\Local\Google\Chrome\User 
Data\Default\Current Tabs", "r")
Current_Tabs_Raw = Current_Tabs_Source.read()
print(Current_Tabs_Raw) #just for checking 

PermissionError: [Errno 13] Permission denied

Opening through sglite3 - does not work, because it is blocked. And I can’t find the password anywhere. Ive tried to open History for URLs, but it doesn't work anyway.

import sqlite3
from os import path

data_path = path.expanduser('~') + r"\AppData\Local\Google\Chrome\User 
Data\Default"
files = listdir(data_path)
history_db = path.join(data_path, 'history')

c = sqlite3.connect(history_db)
cursor = c.cursor()
select_statement = "SELECT urls.url, urls.visit_count FROM urls, visits 
WHERE urls.id = visits.url;"
cursor.execute(select_statement)

results = cursor.fetchall()

print(results) #just for checking

sqlite3.OperationalError: database is locked

URL- - , selenium. Windows , , .

Ive -, URL- 30 temp. Javascript, .

- Python? .

+4
1

, .

()

0

Source: https://habr.com/ru/post/1691424/


All Articles