Example #1
0
# -*- coding: utf-8 -*-

import social
import engine
import sys
#import logging
import time
import threading
from datetime import datetime

#logging.basicConfig(filename='indexer.log',level=logging.INFO)

INDEX = 'twitter'
twitter_error = True

alpha = social.api('alpha')
beta = social.api('beta')
gamma = social.api('gamma')
api = alpha

#thread = list()
def worker(api, friends):

    timestamp_start = str(datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d %H:%M:%S'))
    log_start = str((threading.currentThread().getName(), 'Launched'))
    start = log_start + ':' + timestamp_start
    print start

    for friend in friends:
        engine.index(INDEX, 'user', friend.id, social.userToJSON(friend))
Example #2
0
#logging.basicConfig(filename='indexer.log',level=logging.INFO)

INDEX = 'scrapy'

accounts = config.value(['twitter','accounts'])

timestamp_start = str(datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d %H:%M:%S'))
start = 'Start: ' + timestamp_start
print start

if (len(sys.argv)==2):
    api_param = sys.argv[1]
else:
    raise Exception('Error en cantidad de parametros ingresados!!!')

api = social.api(api_param)

for account in accounts:
    print 'Indexing ' + account
    user = social.GetUser(api,account)
    id = user.__getattribute__('_id')
    engine.index(INDEX, 'user', id, social.userToJSON(user))

    request={"size":1,"sort":[{"id":{"order":"desc"}}], "query": {"match": {
                 "user.screen_name":account}}}

    docs = engine.search(INDEX, 'tweet', request)
    if (len(docs["hits"]["hits"]) > 0):
        since_id = str(docs["hits"]["hits"][0][u'_id'])
    else:
        since_id = None
Example #3
0
# -*- coding: utf-8 -*-

import social
import engine
import sys
#import logging
import time
import threading
from datetime import datetime

#logging.basicConfig(filename='indexer.log',level=logging.INFO)

INDEX = 'twitter'
twitter_error = True

alpha = social.api('alpha')
beta = social.api('beta')
gamma = social.api('gamma')
api = alpha


#thread = list()
def worker(api, friends):

    timestamp_start = str(
        datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d %H:%M:%S'))
    log_start = str((threading.currentThread().getName(), 'Launched'))
    start = log_start + ':' + timestamp_start
    print start

    for friend in friends:
Example #4
0
#logging.basicConfig(filename='indexer.log',level=logging.INFO)

INDEX = 'scrapy'

accounts = config.value(['twitter','accounts'])

timestamp_start = str(datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d %H:%M:%S'))
start = 'Start: ' + timestamp_start
print(start)

if (len(sys.argv)==2):
    api_param = sys.argv[1]
else:
    raise Exception('Error en cantidad de parametros ingresados!!!')

api = social.api(api_param)

for account in accounts:
    print('Indexing ' + account)
    user = social.GetUser(api,account)
    id = user.id
    engine.index(INDEX, 'user', id, social.userToJSON(user))

    request={"size":1,"sort":[{"id":{"order":"desc"}}], "query": {"match": {
                 "user.screen_name":account}}}

    docs = engine.search(INDEX, 'tweet', request)
    if (len(docs["hits"]["hits"]) > 0):
        since_id = str(docs["hits"]["hits"][0][u'_id'])
    else:
        since_id = None