Ejemplo n.º 1
0
 # Prep
 import _credentials
 access_tokens = _credentials.access_tokens
 
 gateway = APIGateway( access_tokens=access_tokens, token_hourly_query_quota=500 )
 api = APIWrapper( gateway )
 dbw = DBWrapper()
 
 if True: #~
     from database import Friendship
     if not dbw._get_engine().has_table('friendships'):
         dbw._get_engine().create(Friendship.__table__)
 
 #
 # Begin mining...
 max_crawl_id = dbw.get_friendships_max_crawl_id()
 
 if max_crawl_id is None:
     logging.debug( 'no previous crawls found.' )
     crawl_id = 1
 else:
     crawl_id = max_crawl_id + 1
 
 logging.info( 'crawl id = %s', crawl_id )
 count_users = 0
 sum_degree = 0
 friend_rows_added = 0
 
 all_users = dbw.get_all_users_with_checkins() 
 for indx, user_obj in enumerate( all_users ):
     user_4sq_id = user_obj.foursq_id