Files
Slonix/main.py
2024-07-26 01:23:15 +09:00

60 lines
2.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import mainparser
import timeit
from multiprocessing import Process
def main(dateArr, url):
#proxy = '152.26.229.42:9443'
threads = []
totalGuys, config, filepath, noAI, limit = mainparser.getConf()
st_accept = "text/html"
st_useragent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:123.0) Gecko/20100101 Firefox/123.0"
headers = {
"Accept": st_accept,
"User-Agent": st_useragent}
for i in dateArr:
print(f"{url}{i}/", i, totalGuys, config, filepath)
thread = Process(target=mainparser.process, args=(f"{url}{i}/", i, totalGuys, config, filepath, headers, noAI, limit))
threads.append(thread)
# print(1)
# print(len(threads), threads)
for thread in threads:
thread.start()
for thread in threads:
thread.join()
# for i in dateArr:
# run(process(f"https://ria.ru/{i}/", i))
if __name__ == "__main__":
#dateArr = '20240501,20240502'.split(',')
dateArr = mainparser.preparing()
'''Эй, сделай вот тут снизу выбор зеркалов'''
url = 'https://ria.ru/'
'''
Железо на которых запускалось сие творение:
{'кол-во потоков' : 'время за которое выполняется задача'}
Даты: 20240501,20240502
ТКУ:
{'1': 88.7175525999628}
{'2': 55.970715400064364} +55% прирост к скорости
2СР (асинхрон, мобильный инет):
{'2': 15.931628999998793} +251% или 457% (с одним потоком) (на мобильном инете!!)
Старшина (асинхрон, мобильный инет):
{'2': 76.97899259999758}
Старшина (асинхрон, 40 ссылок, мобильный инет, лимит 7):
{'2': 69.63641009999992}
'''
'''Что еще можно сделать:
1. перестать пользоваться БЯМ и/или добавить фильтр по тегам
2. добавить прогрузку последующих новостей через гет-реквест +
3. собрать через нуитку +'''
dataTime = {f'Tasks/Time: {len(dateArr)}' : timeit.timeit('main(dateArr, url)', number=1, globals=globals())}
print(dataTime)