pre_user = None pre_users = [] # input: cur_user while True: cur_step = cur_step + 1 # increase step print '=========== Current Step:',cur_step pre_user = None if len(pre_users)==0 else pre_users[-1] print "STEP, USERS = ", cur_step, ", ", len(users) try: # get the user basic information if users.has_key(cur_user["id"]) == True: print "VISITED USER: "******"username"], cur_user["id"] user_profile = users[cur_user["id"]] else: print "NEW USER: "******"username"], cur_user["id"] user_profile = behance.get_user(cur_user["id"]) # save the user info if not saved before (check with users) users[cur_user["id"]] = user_profile dbusers.insert(json.loads(json.dumps(user_profile.copy()), object_hook=remove_dot_key)) # cache # dbcache.insert({'type':'user', 'key':str(cur_user['id']), # 'value':json.loads(json.dumps(user_profile.copy()),\ # object_hook=remove_dot_key)}) # create a link if pre_user!=None and side==FOLLOWED: key = str(pre_user['id']) + str(cur_user['id']) if visited_links.has_key(key)==False: print 'CREATE FOLLOWED LINK (', pre_user['id'], cur_user['id'],')' dblinks.insert({ 'follower_id': pre_user['id'], 'followee_id': cur_user['id']})