How can i determine using java what sites have been opened up in browsers?
I need to understand the directions in need to look into to Writing a program that figures out what all websites have been hit by a user using his browser. I 开发者_运维知识库want to write a standalone program. Can anybody direct me to some API which may help me figure this out.
Well, first of all that depends on which browser do you need to check. I'm guessing that you need to check the currently set default system browser. Anyway, that will require a lot of browser research and few JNI calls.
- To find a default browser you would need to check
HKEY_CLASSES_ROOT\http\shell\open\command
(for Windows) and various configuration files under different linux for different window managers. - Then you would need to read the history of the specific browser from the format of that browser. For example, Firefox stores it's history in
sqlite
format in the profile directory inplaces.sqlite
file. Chrome on other hand stores it in%home%/User Data/Default/history
. So you would need a separate parser for each browser.
Basically, if you need a universal browser history reader - it's a load of work and research.
As it was clarified by the author in his comments - he needs to check what is user currently browsing.
The only truly browser and OS independent way is through proxy. You need to create a HTTP(S) proxy with Java (there are some implementations out there already) and then reconfigure the desired browser to use the proxy running at localhost. When your proxy is used - it will be able to track every bit of traffic the user tries to load.
This information is stored in a SQLite database in firefox:
The file "places.sqlite" stores the annotations, bookmarks, favorite icons, input history, keywords, and browsing history (a record of visited pages).
http://kb.mozillazine.org/Places.sqlite
Other browsers probably have similar approaches.
Any language with drivers for SQLite, and that includes Java, C, C#, C++, ruby, and, yes, even javascript, should be equally capable of accessing this database.
Speaking for myself, I would be interested collaborating on such a stand-alone program in Java should the OP put his code on github.
精彩评论