Python: Getting all Urls from every open Google Chrome Tab
1403 观看
1回复
51 作者的声誉
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
Ive tried:
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.
Ive considered hacking together a chrome extension that copys the urls every 30 sec to a temp file. But i only know minimal Javascript so this thing is driving me mad.
So does anyone know a way to do this in Python ? Any other solution is greatly appreciated.
作者: Beni G 的来源 发布者: 2017 年 12 月 27 日回应 1
来自类别的问题 :
- python 如何使用Python的itertools.groupby()?
- python Python:我在运行什么操作系统?
- python 如何使用Python创建可直接执行的跨平台GUI应用程序?
- python Python声音(“钟声”)
- python-3.x 我可以在同一台Windows计算机上安装Python 3.x和2.x吗?
- python-3.x Python 3中execfile的替代方法是什么?
- python-3.x 移除Python unicode字符串中的重音符号的最佳方法是什么?
- python-3.x 删除Tkinter窗口上的TK图标
- google-chrome 如何在Google Chrome中启动JavaScript调试程序?
- google-chrome 使用JavaScript获取图像的实际宽度和高度?(在Safari / Chrome中)
- google-chrome 为什么Chrome没有其他浏览器时会报告安全/非安全警告?
- google-chrome Chrome中选择选项元素上的Click事件
- selenium 有没有办法同时运行Bamboo测试?
- selenium 硒xpath流
- selenium 访问Firefox中的文件下载对话框
- selenium 如何在使用Selenium时禁用Javascript?
- sqlite 如何转储某些SQLite3表的数据?
- sqlite 如何合并许多SQLite数据库?
- sqlite 如何确定SQLite索引是否唯一?(使用SQL)
- sqlite Hibernate的轻量级替代品?