Created
July 21, 2011 22:42
-
-
Save sbp/1098414 to your computer and use it in GitHub Desktop.
Swhack search script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import sys, os, time, urllib | |
print 'Content-Type: text/plain; charset=utf-8' | |
query = os.environ['QUERY_STRING'] | |
query = urllib.unquote(query) | |
query = query.lower() | |
now = time.time() | |
day = 24 * 60 * 60 | |
for i in xrange(28): | |
offset = day * i | |
d = time.gmtime(now - offset) | |
name = 'logs/%04i-%02i-%02i.txt' % (d[0], d[1], d[2]) | |
try: f = open(name) | |
except IOError, OSError: continue | |
for line in reversed(list(f)): | |
if query in line.lower(): | |
if '.o swhack' in line: continue | |
if '<phenny>' in line: continue | |
print '%04i-%02i-%02i' % (d[0], d[1], d[2]), line | |
f.close() | |
sys.exit(0) | |
f.close() | |
print 'No result in past month for "%s".' % query |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment