Python: Getting all Urls from every open Google Chrome Tab
I need to get all the urls from all open Google Chrome tabs in python 3 without intefering with the user. Im on Windows 10 using Microsoft Visual Studio Python3
Opening it directly with open(path to current tabs)-- doesnt work because i have no permission- i think its locked because chrome activly writes 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 -- doesnt work because its locked. And i cant find a password anywhere. Ive tried to open the History for the urls but it doesnt work anyways.
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
Using selenium and a 3rd party chrome extension to copy all urls to the clipboard -- doesnt work because these extensions only work in the active selenium window. So the Windows with the tabs in it that i want dont get copied.
So does anyone know a way to do this in Python ? Any other solution is greatly appreciated.作者: Beni G 的来源 发布者: 2017 年 12 月 27 日