def main(num): seeds = ['75007332', '1316932982', '261467131'] #check init or restart if os.path.exists(path + "que_" + seeds[num - 1] + "_fr.pickle"): que_fr = load_pickle(path, "que_" + seeds[num - 1] + "_fr") que_fo = load_pickle(path, "que_" + seeds[num - 1] + "_fo") else: que_fr = seeds[num - 1] que_fr = seeds[num - 1] start_time = time.time() while (1): user = que.pop() print("user start : {0}".format(user)) friend, follower = graph.update('all', user, 'nnn') for ad_fr in friend: flag = database.check(ad_fr) if flag != "protected" and flag != 'NotFound': que_fr.insert(0, ad_fr) for ad_fo in follower: flag = database.check(ad_fo) if flag != "protected" and flag != 'NotFound': que_fr.insert(0, ad_fr) end_time = time.time() if end_time - start_time > 1800: Mypickle.save(path, que_fr, "que_" + seeds[num - 1] + "_fr") Mypickle.save(path, que_fo, "que_" + seeds[num - 1] + "_fo") start_time = end_time
def basic_pass2(seed): match_list = [] followers = update("followers_only",seed, seed) if not os.path.isfile(DIR + seed + '_2.pickle'): Mypickle.save(DIR, followers, seed + '_2') return followers
def basic_pass1(seed): match_list = [] friends = update("friends_only",seed, seed) if not os.path.isfile(DIR + seed + '_1.pickle'): Mypickle.save(DIR, friends, seed + '_1') return friends
def basic_pass7(seed): match_list = [] friends, followers = update("all",seed,seed) if not os.path.isfile(DIR + seed + '_1.pickle'): Mypickle.save(DIR, friends, seed + '_1') if not os.path.isfile(DIR + seed + '_2.pickle'): Mypickle.save(DIR, followers, seed + '_2') match_list = list(set(followers) & set(friends)) return match_list
def basic_pass3(seed): match_list = [] friends = update("friends_only",seed ,seed) if not os.path.isfile(DIR + seed + '_1.pickle'): Mypickle.save(DIR, friends, seed + '_1') for friend in friends: followers = update("followers_only",friend, seed) match_list = list(set(match_list) | set(followers)) if not os.path.isfile(DIR + seed + '_3.pickle'): Mypickle.save(DIR, match_list, seed + '_3') return match_list
def basic_pass4(seed): match_list = [] followers = update("followers_only",seed, seed) if not os.path.isfile(DIR + seed + '_2.pickle'): Mypickle.save(DIR, followers, seed + '_2') for follower in followers: friends = update("friends_only",follower, seed) match_list = list(set(match_list) | set(friends)) if not os.path.isfile(DIR + seed + '_4.pickle'): Mypickle.save(DIR, match_list, seed + '_4') return match_list
def basic_pass18(seed): match_list = [] fofo = [] followers = update("followers_only", seed,seed) if not os.path.isfile(DIR + seed + '_2.pickle'): Mypickle.save(DIR, followers, seed + '_2') for follower in followers: followers2followers = update("followers_only",follower,seed) fofo = list(set(followers2followers) & set(fofo)) ans = list(set(followers) & set(followers2followers)) match_list = list(set(match_list) | set(ans)) if not os.path.isfile(DIR + seed + '_3.pickle'): Mypickle.save(DIR, fofo, seed + '_3') return match_list
def basic_pass17(seed): match_list = [] frfr = [] friends = update("friends_only", seed,seed) if not os.path.isfile(DIR + seed + '_1.pickle'): Mypickle.save(DIR, friends, seed + '_1') for friend in friends: friends2friends = update("friends_only",friend,seed) frfr = list(set(friends2friends) & set(frfr)) ans = list(set(friends) & set(friends2friends)) match_list = list(set(match_list) | set(ans)) if not os.path.isfile(DIR + seed + '_5.pickle'): Mypickle.save(DIR, frfr, seed + '_5') return match_list
def basic_pass11(seed): match_list = [] friends, followers = update("all",seed,seed) if not os.path.isfile(DIR + seed + '_1.pickle'): Mypickle.save(DIR, friends, seed + '_1') if not os.path.isfile(DIR + seed + '_2.pickle'): Mypickle.save(DIR, followers, seed + '_2') mutual = list(set(followers) & set(friends)) mutual = list(set(mutual) - set(seed)) for m in mutual: ans = update("followers_only", m,seed) match_list = list(set(match_list) | set(ans)) return match_list
def basic_pass33(seed): match_list = [] frfr = [] frfo = [] friends, followers = update("all", seed,seed) if not os.path.isfile(DIR + seed + '_1.pickle'): Mypickle.save(DIR, friends, seed + '_1') if not os.path.isfile(DIR + seed + '_2.pickle'): Mypickle.save(DIR, followers, seed + '_2') for friend in friends: friends2friends, friends2followers = update("all",friend,seed) frfr = list(set(friends2friends) & set(frfr)) frfo = list(set(friends2followers) & set(frfo)) ans = list(set(followers) & set(friends) & set(friends2followers) & set(friends2followers)) match_list = list(set(match_list) | set(ans)) if not os.path.isfile(DIR + seed + '_5.pickle'): Mypickle.save(DIR, frfr, seed + '_5') if not os.path.isfile(DIR + seed + '_3.pickle'): Mypickle.save(DIR, frfo, seed + '_3') return match_list
def basic_pass21(seed): match_list = [] fofr = [] friends, followers = update("all", seed,seed) if not os.path.isfile(DIR + seed + '_1.pickle'): Mypickle.save(DIR, friends, seed + '_1') if not os.path.isfile(DIR + seed + '_2.pickle'): Mypickle.save(DIR, followers, seed + '_2') for follower in followers: followers2friends = update("friends_only",follower,seed) fofr = list(set(followers2friends) & set(fofr)) ans = list(set(friends) & set(followers) & set(followers2friends)) match_list = list(set(match_list) | set(ans)) if not os.path.isfile(DIR + seed + '_4.pickle'): Mypickle.save(DIR, fofr, seed + '_4') return match_list
def personal_check(queryID, pattern, match_list, match_seeds, seeds_score): match_users = [] for user in match_list: if len( database.select('SELECT * from query where userID = \'' + user[0] + '\' AND queryID = \'' + queryID + '\'')) != 0: continue responce = twitter.show(user[0]) if responce.status_code != 200: print("Error code: %d" % (responce.status_code)) continue ress = json.loads(responce.text) print("score : {0}".format(user[1])) print("\n\nhttps://twitter.com/intent/user?user_id=" + user[0]) print( "screen_name:{0}\nuserID:{1}\nusername:{2}\nprofile:{3}\n".format( ress["screen_name"], user[0], ress["name"], ress["description"])) webbrowser_flag = False while (1): print("input true or false or half (help = h)") input_flag = input('>>> ') '''if input_flag == "h": driver = webdriver.Chrome("./chromedriver") driver.get(":) webbrowser_flag = True elif input_flag == "y" or input_flag == "n": y_n[user] = input_flag if webbrowser_flag: driver.close() break''' if input_flag == "true": ID = database.select( "SELECT MAX(ID) from query where queryID = \'" + queryID + "\'") database.insert( "query", (str(int(ID[0][0]) + 1), user[0], queryID, "2")) break elif input_flag == "false": ID = database.select( "SELECT MAX(ID) from query where queryID = \'" + queryID + "\'") database.insert( "query", (str(int(ID[0][0]) + 1), user[0], queryID, "0")) break elif input_flag == "half": ID = database.select( "SELECT MAX(ID) from query where queryID = \'" + queryID + "\'") Mydatavase.insert( "query", (str(int(ID[0][0]) + 1), user[0], queryID, "1")) break else: print("input again!!") print("{0} people checked!!".format(int(ID[0][0]) + 1)) seeds = match_seeds[user[0]] if input_flag == "true": seeds_score = update_score(input_flag, pattern, seeds, seeds_score) seeds_score = init_score(user[0], seeds_score) match_users.append(user[0]) else: seeds_score = update_score(input_flag, pattern, seeds, seeds_score) Mypickle.save(path, seeds_score, "seeds_score_" + queryID) continue_flag, next_pattern = passcheck_continue(pattern, seeds_score) if continue_flag is True or (continue_flag is False and input_flag == "true"): break return match_users, next_pattern, seeds_score
node2node[user]["friend"].append(i) for i in ans_follower: node2node[user]["follower"].append(i) print(ans_friend) print(ans_follower) print( "friend : {0}\nfollower : {1}\nfriend2friend : {2}\nfriend2follower : {3}\n follower2friend : {4}\nfollower2follower : {5}\n" .format(len(node2node[user]["friend"]), len(node2node[user]["follower"]), len(node2node[user]["friend2friend"]), len(node2node[user]["friend2follower"]), len(node2node[user]["follower2friend"]), len(node2node[user]["follower2follower"]))) Mypickle.save("../query/analysis/", node2node, queryID + "_node2node") graph_count = [0] * 39 p_dic = { "friend": 1, "follower": 2, "friend2follower": 3, "follower2friend": 4, "friend2friend": 5, "follower2follower": 6 } for user in (seeds + match): node = node2node[user] #dic