Пример #1
0
exchange_list=[i[8:] for i in os.listdir("TimeLine") if not i[0]=="."]
all_list=set(rand_list+exchange_list)
all_list.remove(CCAA.target)
all_list=list(all_list)
random.shuffle(all_list)
pick=[]
for i in all_list[:10]:
    i = clone.user_info(i)
    if not i is None:
        ids,name = i["id"],i["name"]
        print (name)
        pick+=clone.follow_exchanger(ids)
pick=[i for i in pick if not i in all_list]
random.shuffle(pick)
count=0
start_time=-1
for i in pick[:30]:
    ids=i
    print ("get ",ids ,"'s tweet")
    if start_time == -1:
        count=0
        start_time =time.time()
    words,num=textTools.create_train(ids,path="random_TimeLine/")
    count+=num

    if count >= 150:
        sleep_time = 900 - (time.time()-start_time) if 900 - (time.time()-start_time) > 0 else 0
        print ("limit!! sleep : ",sleep_time,"s")
        time.sleep(sleep_time)
        start_time=-1
Пример #2
0
        start_time =time.time()
    count+=1
    for i in infos:
        if not "bot" in i["description"] and not i["protected"]:
            new_list.append([i["id_str"],i["name"]])

    his_list=his_list[100:]
    print "get ",count*100," follower"
    if count == 180:
        sleep_time = 900 - (time.time()-start_time) if 900 - (time.time()-start_time) > 0 else 0
        print "limit!! sleep : ",sleep_time,"s"
        time.sleep(sleep_time)
        count = -1
        start_time=-1

count=0
start_time=-1
for i in new_list:
    ids,name = i
    print "get ",name ,"'s tweet "
    if start_time == -1:
        count=0
        start_time =time.time()
    words,num=textTools.create_train(ids)
    count+=num
    if count >= 150:
        sleep_time = 900 - (time.time()-start_time) if 900 - (time.time()-start_time) > 0 else 0
        print "limit!! sleep : ",sleep_time,"s"
        time.sleep(sleep_time)
        start_time=-1