本文整理汇总了Python中Stream.Stream.getUserList方法的典型用法代码示例。如果您正苦于以下问题:Python Stream.getUserList方法的具体用法?Python Stream.getUserList怎么用?Python Stream.getUserList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stream.Stream
的用法示例。
在下文中一共展示了Stream.getUserList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start
# 需要导入模块: from Stream import Stream [as 别名]
# 或者: from Stream.Stream import getUserList [as 别名]
def start(self, users):
#users is a list of dictionary type objects
# dict type objects from getConfig()
print "Starting..."
#start Twitter stream
streamThreads = []
streamBuffers = []
for user in users:
sr = Stream(user['con_key'], user['con_secret'],
user['key'], user['secret'],
user['name'])
#insert user list into db
list = sr.getUserList(self.parseLists(user['lists']))
self.sql.insert_into_userList(list, user['db'])
track = []
for keyword in user['track'].split(','):
track.append(keyword)
#get buffer and run stream
buff = sr.getTweetsBuffer()
# if list is not None or track is not None:
# stream = sr.run(list, track)
# else:
# stream = sr.run(None)
stream = sr.run(list, track)
#add new buff and stream to list
streamBuffers.append({'buff':buff, 'db':user['db']})
streamThreads.append(stream)
print "Started user: " + user['name']
self.logger.info("Started user: " + user['name'])
while True:
try:
for buffer in streamBuffers:
tweet = buffer['buff'].pop()
if not tweet:
time.sleep(1)
else:
self.sql.insert_into(buffer['db'], tweet)
except KeyboardInterrupt:
print "Exiting..."
os._exit(0)
示例2: start
# 需要导入模块: from Stream import Stream [as 别名]
# 或者: from Stream.Stream import getUserList [as 别名]
def start(self, users):
print "Starting..."
#start Twitter stream
streamThreads = []
streamBuffers = []
for user in users:
sr = Stream(user['con_key'], user['con_secret'],
user['key'], user['secret'],
user['name'])
#insert user list into db
list = sr.getUserList(self.parseLists(user['lists']))
self.sql.insert_into_userList(list, user['db'])
#get buffer and run stream
buff = sr.getTweetsBuffer()
if list is not None:
stream = sr.run(list)
else:
stream = sr.run(None)
#add new buff and stream to list
streamBuffers.append({'buff':buff, 'db':user['db']})
streamThreads.append(stream)
print "Started user: " + user['name']
self.logger.info("Started user: " + user['name'])
while True:
try:
for buffer in streamBuffers:
tweet = buffer['buff'].pop()
if not tweet:
time.sleep(1)
else:
self.sql.insert_into(buffer['db'], tweet)
except KeyboardInterrupt:
print "Exiting..."
os._exit(0)