0

Is it possible to get the current firefox tab's link using python, assuming that only one firefox instance is running? So let's say I have a firefox instance running that has three tabs. Tab three is currently selected. It's on https://stackoverflow.com/. Now I want to run my python application and get https://stackoverflow.com/.

What I have done so far

Selenium Solution

Someone posted this Selenium solution, but Selenium feels really heavy for this task and so far it seems unable to distinguish the currently selected "foreground" tab.

get active url on chrome and firefox using python

Read into webbrowser

First I thought that maybe the controller object of webbrowswer might help me out, but it can only be used to open pages not get any information out of the browser afterwards: https://docs.python.org/3/library/webbrowser.html

get_firefox_urls

This is able to get the urls as well, but also doesn't differentiate between "background"/not selected tabs and the "foreground"/selected tab. Also I get NameError: name 'os' is not defined while trying to import from the module so I think it is broken.

firefox profile

I tried the example code on that website as it mentioned a last accessed date which would probably allow me to identify the currently selected tab as it was last accessed. However, the example didn't work for me. I've opened an issue: https://github.com/luismsgomes/firefox-profile/issues/1

Natan
  • 728
  • 1
  • 7
  • 23

0 Answers0