|
@ -69,10 +69,10 @@ def htmlFetch(page, thread: int = 1, delay: float = 1, proxy: str = ''): # fetc |
|
|
logger.info('Html fetch proxy -> `%s`' % proxy) |
|
|
logger.info('Html fetch proxy -> `%s`' % proxy) |
|
|
threadPool = ThreadPoolExecutor(max_workers = thread) |
|
|
threadPool = ThreadPoolExecutor(max_workers = thread) |
|
|
threads = [] |
|
|
threads = [] |
|
|
while True: |
|
|
while True: # traverse generator |
|
|
try: |
|
|
try: |
|
|
threads.append(threadPool.submit(pageFetch, next(page), delay, proxy)) |
|
|
threads.append(threadPool.submit(pageFetch, next(page), delay, proxy)) # add task |
|
|
except StopIteration: |
|
|
except StopIteration: |
|
|
break |
|
|
break |
|
|
futures.wait(threads, return_when = ALL_COMPLETED) |
|
|
futures.wait(threads, return_when = ALL_COMPLETED) # wait all task complete |
|
|
logger.info('Html fetch complete') |
|
|
logger.info('Html fetch complete') |
|
|