script/rest/getscreennames.py
changeset 9 bb44692e09ee
child 891 8628c590f608
equal deleted inserted replaced
8:b7f4b0554ef8 9:bb44692e09ee
       
     1 from sqlite3 import *
       
     2 import datetime, time
       
     3 import email.utils
       
     4 from optparse import OptionParser
       
     5 import os.path
       
     6 import os
       
     7 import sys
       
     8 import simplejson
       
     9 import re
       
    10 
       
    11 if __name__ == "__main__" :
       
    12 
       
    13     parser = OptionParser()
       
    14 
       
    15     (options, args) = parser.parse_args()
       
    16     
       
    17     conn = connect(args[0])
       
    18     conn.row_factory = Row
       
    19     curs = conn.cursor()
       
    20     
       
    21     names = {}
       
    22     
       
    23     curs.execute("select tt.text as text from tweet_tweet as tt left join tweet_user as tu on tt.user = tu.rowid where tt.text like \"%ENMI09%\" order by tt.created_at_ts asc;")
       
    24     
       
    25     regexp = re.compile("\@(\w+)")
       
    26     
       
    27     for row in curs:
       
    28         text = row["text"]
       
    29         for m in regexp.finditer(text):
       
    30             names[m.group(1)]=m.group(1)
       
    31     
       
    32     
       
    33     print repr(names.keys())
       
    34     print repr(len(names.keys()))
       
    35             
       
    36