equal
deleted
inserted
replaced
1 from iri_tweet import models, utils |
1 from iri_tweet import models, utils |
2 from sqlalchemy.orm import sessionmaker |
2 from sqlalchemy.orm import sessionmaker |
3 import anyjson |
3 import anyjson |
4 import sqlite3 |
4 import sqlite3 |
5 import twitter |
5 import twitter |
|
6 import re |
6 from optparse import OptionParser |
7 from optparse import OptionParser |
7 |
8 |
8 |
9 |
9 def get_option(): |
10 def get_option(): |
10 |
11 |
33 |
34 |
34 if __name__ == "__main__": |
35 if __name__ == "__main__": |
35 |
36 |
36 (options, args) = get_option() |
37 (options, args) = get_option() |
37 |
38 |
38 twitter = twitter.Twitter(domain="search.twitter.com") |
39 t = twitter.Twitter(domain="search.twitter.com") |
|
40 t.secure = False |
39 |
41 |
40 conn_str = args[0].strip() |
42 conn_str = args[0].strip() |
41 if not re.match("^\w+://.+", conn_str): |
43 if not re.match("^\w+://.+", conn_str): |
42 conn_str = 'sqlite:///' + conn_str |
44 conn_str = 'sqlite:///' + conn_str |
43 |
45 |
51 #curs.execute("create table if not exists tweet_tweet (json);") |
53 #curs.execute("create table if not exists tweet_tweet (json);") |
52 #conn.commit() |
54 #conn.commit() |
53 |
55 |
54 results = None |
56 results = None |
55 page = 1 |
57 page = 1 |
|
58 print options.query |
56 |
59 |
57 while page <= int(1500/int(options.rpp)) and ( results is None or len(results) > 0): |
60 while page <= int(1500/int(options.rpp)) and ( results is None or len(results) > 0): |
58 results = twitter.search(q=options.query, rpp=options.rpp, page=page) |
61 results = t.search(q=options.query, rpp=options.rpp, page=page, include_entities=True) |
|
62 |
59 for tweet in results["results"]: |
63 for tweet in results["results"]: |
60 print tweet |
64 print tweet |
61 tweet_str = anyjson.serialize(tweet) |
65 tweet_str = anyjson.serialize(tweet) |
62 #invalidate user id |
66 #invalidate user id |
63 processor = utils.TwitterProcessor(tweet, tweet_str, None, session, None, options.token_filename) |
67 processor = utils.TwitterProcessor(tweet, tweet_str, None, session, None, options.token_filename) |