Created
March 10, 2021 22:25
-
-
Save roeeyn/8eee43be4f75af89ff0ac737f540efb7 to your computer and use it in GitHub Desktop.
Get All Open Chrome Tabs With Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
from datetime import datetime | |
def read_articles_tabs(): | |
articles = os.popen( | |
"""osascript -e{'set o to""','tell app"google chrome"','repeat with t in tabs of windows','set o to o&url of t&" "&title of t&linefeed',end,end}|sed \$d""" | |
).read() | |
return [ | |
(lambda param: [param[0], " ".join(param[1:]).strip().replace("\n", "")])( | |
article.split(" ") | |
) | |
for article in articles.split("\n") | |
if article != "" | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment