Getting current url from firefox using python

I want to know what is the current URL of the active tab for starting a firefox instance from the python module. Does FireFox have an API for this and does python know how to work with it?

+4
source share
4 answers

The most convenient way might be the insatll firefox extension to open the tcp service, then you can exchange information with firefox.

mozrepl can configure the telnet service, you can call the js-like command to get the information.

With telnetscript (http://code.activestate.com/recipes/152043/) you can write:

import telnetscript script = """rve w content.location.href; ru repl> w repl.quit() cl """ conn = telnetscript.telnetscript( '127.0.0.1', {}, 4242 ) ret = conn.RunScript( script.split( '\n' )).split( '\n' ) print ret[-2][6:] 
+2
source

If on windows you can use win32com

 import win32clipboard import win32com.client shell = win32com.client.Dispatch("WScript.Shell") shell.AppActivate('Some Application Title') 

Then use shell.SendKeys to do ctrl + l and ctrl + c

Then read the line on the clipboard.

This is a ferret, although it will work, alternatively you can use something like AutoIt to compile code in exe that you can work with.

Hope this helps.

+1
source

Python also has a webbrowser module, but it seems to let you open new windows / tabs.

0
source

I think I found something that can help me.

-1
source

All Articles