Get url from webbrowser in python
I would like 开发者_C百科to ask how can I get list of urls which are opened in my webbrowser, from example in firefox. I need it in Python. Thanks
Try either SeleniumRC - which is very good
or https://github.com/bard/mozrepl/wiki/
You can use it with python as described here
http://www.craigethomas.com/blog/2009/04/get-android-market-stats-with-python-mozrepl-and-beautifulsoup/
But I would go the selenium route for anything not trivial
First I'd check if the browser has some kind of command line argument which could print such informations. I only checked Opera and it doesn't have one. What you could do is parse session file. I'd bet that every browser stores list of opened tabs/windows on disk (so it could recover after crash). Opera has this information in ~/.opera/sessions/autosave.win
. It's pretty straight-forward text file. Find other browsers' session files in .mozzila, .google, etc.. or if you are on windows in /user/ directories. There might be commands to ask running instance for its working directory (as you can specify it on startup and it doesn't have to be the default one).
That's the way I'd go. Might be the wrong one.
精彩评论