|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
||||
|
||||
|
I've seen this question and quite a few answers in PHP and I'm getting some ideas for doing it in python. That is finding out who's online at any particular time on a particular webpage.
I'm guessing I'll be using some kind of temp file and the os.environ["REMOTE_ADDR"] function, but I was wondering if anybody had any ideas or snippets of success before? Thanks, Benjamin |
|
#2
|
|||
|
|||
|
"online at any particular time on a particular webpage"? You mean like on here? The only real way to do it, unless there's some sort of other way to access that data, is to just parse the webpage for it.
|
|
#3
|
||||
|
||||
|
Yes, online at that particular moment for that webpage, similar to the way devshed's forums have at the bottom user's and who they are. Any ideas?
Thanks, Benjamin |
|
#4
|
||||
|
||||
|
Surly to get the info your program would have to be on the webserver your tageting.
Quote:
it's got to be hard if not impossibe to just pick a website and get a list or remote IP's on that page.. maybe you could post a few links to the idea's you were given on how to do it in PHP? Mark |
|
#5
|
||||
|
||||
|
Sorry should have made that clear, it's for my own site. It's got php, so I could use that, but I'd rather do it in python as not only do I like python more, I've already got python code running.
So yes, I've got access to the server, all the cgi variables and wish to go about doing something like this(php, sorry for the length) get's who's online using files: PHP Code:
in python. Cheers, Benjamin |
|
#6
|
||||
|
||||
|
OK, this should do the same thing! it's untested and could be improved a little but hey
![]() Code:
import os, time
filename = 'data.txt'
timenow = time.time() - 300
online = {}
file(filename, 'a').write(str(os.environ('REMOTE_ADDR')) + '-' + str(time.time()) + '\n')
for user in file(filename, 'r').readlines():
user = user.strip().split('-')
if user[1] >= timenow:
online[user[0]] = user[1]
users = ', '.join(online.keys())
if len(online.keys()) == 1:
print 'User online:', users
else:
print 'Users online:', users
Have fun, Mark. Last edited by netytan : October 8th, 2003 at 10:23 AM. |
|
#7
|
||||
|
||||
|
Thanks Mark, I'll have a play and check it out.
Cheers, Benjamin |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > finding who's online |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|