Goal is to have an input file and seperated output.txt files, maybe you can help me here to
It should be something with line 45
And i'm not really advanced so my try may contains some wrong code, I don't know
As an example hashtags for input.txt I used the: wqddt & d2deltas
from instaloader import Instaloader import threading import io import time import sys class LockedIterator(object): def __init__(self, it): self.lock = threading.Lock() self.it = it.__iter__() def __iter__(self): return self def __next__(self): self.lock.acquire() try: return self.it.__next__() finally: self.lock.release() f = open('input.txt','r',encoding='utf-8') HASHTAG = f.read() p = HASHTAG.split('\n') PROFILE = p[:] for ind in range(len(PROFILE)): pro = PROFILE[ind] posts = Instaloader(sleep=False).get_hashtag_posts(pro) posts = LockedIterator(posts) users = set() start_time = time.time() PROFILE = p[:] def worker(): for ind in range(len(PROFILE)): pro = PROFILE[ind] try: filename = 'downloads/'+pro+'.txt' fil = open(filename,'a',newline='',encoding="utf-8") for post in posts: hashtags = post.owner_username fil.write(str(hashtags)+'\n') except: print('Skipping',pro) threads = [] for i in range(4): #Input Threads t = threading.Thread(target=worker) threads.append(t) t.start() for t in threads: t.join() end_time = time.time() print("Done") print("Time taken : " + str(end_time - start_time) + "sec")
usersaset()instead of a list. For multithreading, maybe divide the posts list into 4 parts and execute the loop for them in 4 threads separately. Merge theusersset from each of them at the end.