Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
# -*- coding: utf-8 -*-
# Script:
import accesslog_parse_mongo
import sys
from datetime import datetime, timedelta
def main():
(mongo_connection, mongo_db, mongo_collection) = \
# Get time > now()-1day and url=sys.argv[1]
if len(sys.argv) > 1:
query = {'timestamp': {'$gt': - timedelta(days=1)},
'url': sys.argv[1]}
query = {'timestamp': {'$gt': - timedelta(days=1)}}
entries = mongo_collection.find(query, )
print "There are %i visits from:" % entries.count()
for entry in entries:
print " - %s at %s from %s" % \
(entry['client_ip'], entry['time'], entry['referer'])
if __name__ == '__main__':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment