Hello guys,
I am trying to create a simple program in C# to check how long someone is connected and actively using facebook.
I have made the general layout for it (found here: Paste Code ), but from what I have done, I can only check whether the website server is online or not (and if it is then it will start counting).
How would I check if the user is actually connecting to the website through a web browser?
- Is there a class that check's what website your connecting to?
Also, I would like the counter to only start when the tab on the browser is actually highlighted...
Any idea's?
6 replies to this topic
#1
Posted 16 June 2011 - 10:30 AM
|
|
|
#2
Posted 17 June 2011 - 07:07 AM
This can likely only be done by writing a browser plugin, since you indicated you want to know how long the user is on a certain website, from the time the tab is opened to, I presume, the time the tab is closed or the user navigates away from the site. You'll need the browser's API to have access to this data.
Take a look at the plugin API's for the browser of your choice, and see if you can find some methods that report the URL's of all open tabs. Your plugin could receive events each time a new webpage is accessed, and start an internal timer the first time a URL comes back with "facebook.com" as the domain.
Take a look at the plugin API's for the browser of your choice, and see if you can find some methods that report the URL's of all open tabs. Your plugin could receive events each time a new webpage is accessed, and start an internal timer the first time a URL comes back with "facebook.com" as the domain.
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid
#3
Posted 17 June 2011 - 09:05 AM
gregwarner said:
This can likely only be done by writing a browser plugin, since you indicated you want to know how long the user is on a certain website, from the time the tab is opened to, I presume, the time the tab is closed or the user navigates away from the site. You'll need the browser's API to have access to this data.
Take a look at the plugin API's for the browser of your choice, and see if you can find some methods that report the URL's of all open tabs. Your plugin could receive events each time a new webpage is accessed, and start an internal timer the first time a URL comes back with "facebook.com" as the domain.
Take a look at the plugin API's for the browser of your choice, and see if you can find some methods that report the URL's of all open tabs. Your plugin could receive events each time a new webpage is accessed, and start an internal timer the first time a URL comes back with "facebook.com" as the domain.
Thanks!
But I dont actually know how to program with HTML or Java.. is there a way to do this with C# or do I have to start learning HTML, Java or whatever?
#4
Posted 17 June 2011 - 10:44 AM
Have a look at Mozilla's extension development for Firefox:
Extension development - MozillaZine Knowledge Base
Looks like you can write Mozilla extensions in JavaScript, C++, or Python, according to that page. Of course, there are several other language structures you'll have to learn as well. (Cascading Style Sheets, XML, DOM, RDF)
If you wanted to write one for another browser as well, you'd just have to search for the plugin development references for that browser as well. They might have different language requirements. Perhaps you could write a plugin for IE with C#, but I'm not personally aware of what development languages they support for IE plugins, as I've never had a need to do it.
Extension development - MozillaZine Knowledge Base
Looks like you can write Mozilla extensions in JavaScript, C++, or Python, according to that page. Of course, there are several other language structures you'll have to learn as well. (Cascading Style Sheets, XML, DOM, RDF)
If you wanted to write one for another browser as well, you'd just have to search for the plugin development references for that browser as well. They might have different language requirements. Perhaps you could write a plugin for IE with C#, but I'm not personally aware of what development languages they support for IE plugins, as I've never had a need to do it.
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid
#5
Posted 17 June 2011 - 11:56 AM
another approach to this , which would be less precise than gregwarner's idea, but maybe precise enough, would be to use a proxy solution. This could determine statistics from any browser, and could be set up to track from multiple computers.
Squid is one such proxy server, which can log all requests.
I've attached an example log (viewed through ipcop's log viewer). What I would be proposing, is importing log files periodically, or as you need this information. As you can see, you could approximate time spent on sites or domains or whatever, and filter by machine. Times are posted, so you can approximate.
like 45 requests to facebook, on average 20 - 45 seconds apart, would likley mean active browsing.
Whereas 32 minutes between the next facebook request might mean the user was actually working for a portion of that time.
anywho, just an idea...
Squid is one such proxy server, which can log all requests.
I've attached an example log (viewed through ipcop's log viewer). What I would be proposing, is importing log files periodically, or as you need this information. As you can see, you could approximate time spent on sites or domains or whatever, and filter by machine. Times are posted, so you can approximate.
like 45 requests to facebook, on average 20 - 45 seconds apart, would likley mean active browsing.
Whereas 32 minutes between the next facebook request might mean the user was actually working for a portion of that time.
anywho, just an idea...
Attached Files
#6
Posted 17 June 2011 - 01:21 PM
sam_coder said:
another approach to this , which would be less precise than gregwarner's idea, but maybe precise enough, would be to use a proxy solution. This could determine statistics from any browser, and could be set up to track from multiple computers.
Squid is one such proxy server, which can log all requests.
I've attached an example log (viewed through ipcop's log viewer). What I would be proposing, is importing log files periodically, or as you need this information. As you can see, you could approximate time spent on sites or domains or whatever, and filter by machine. Times are posted, so you can approximate.
like 45 requests to facebook, on average 20 - 45 seconds apart, would likley mean active browsing.
Whereas 32 minutes between the next facebook request might mean the user was actually working for a portion of that time.
anywho, just an idea...
Squid is one such proxy server, which can log all requests.
I've attached an example log (viewed through ipcop's log viewer). What I would be proposing, is importing log files periodically, or as you need this information. As you can see, you could approximate time spent on sites or domains or whatever, and filter by machine. Times are posted, so you can approximate.
like 45 requests to facebook, on average 20 - 45 seconds apart, would likley mean active browsing.
Whereas 32 minutes between the next facebook request might mean the user was actually working for a portion of that time.
anywho, just an idea...
ah, quite a good idea I suppose.. doing it indirectly and with approximation seems a little too much I think (but I may have to if there is no other way).
I just looked at trying to create a plug-in for IE, though again.. seems so long...
Creating a Simple Plug-in
it seems like I need something called " Microsoft Dynamics CRM"
and I still can't figure out how to download and install it... (it seems to need a lot of separate components)
unless I know Java, HTML, CSS it seems like it'll take me a long time to do something thats actually quite simple (in principle).
I dont see the point why they taught us C# at university now.. (I want to make this program using C# to get practice)
What's C# really used for?
#7
Posted 20 June 2011 - 05:56 AM
C# is used for a lot of things. Generally speaking, it's a language in the .NET Framework development tools from Microsoft, which means that it has easy access to all of Microsoft's .NET API's, which can speed up development tremendously if you're writing Windows applications. Moreover, it's frequently used alongside Microsoft's XNA framework for game development on the PC, XBox, Zune, and Windows Phone.
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top










