From 62b927a5c08ac93f1388730773ae5f191b407d38 Mon Sep 17 00:00:00 2001 From: Noretsa Date: Wed, 17 Jun 2020 17:39:58 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BA=D0=BB=D0=B0=D1=81=D1=81=20Users=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D1=81=D0=B1=D0=BE=D1=80=D0=B0=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BD?= =?UTF-8?q?=D0=BE=D0=B2=20=D0=B8=20=D0=BF=D0=B0=D1=80=D0=BE=D0=BB=D0=B5?= =?UTF-8?q?=D0=B9=20=D0=B8=D0=B7=20=D0=BF=D0=B0=D0=BF=D0=BA=D0=B8=20data?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- classes/__init__.py | 0 classes/__pycache__/__init__.cpython-37.pyc | Bin 0 -> 149 bytes classes/__pycache__/users.cpython-37.pyc | Bin 0 -> 1284 bytes classes/users.py | 26 +++++++++++++++ data/domreshetnikovo@gmail.com/pass.txt | 1 + data/osa212@mail.ru/pass.txt | 1 + knd_bot.py | 35 ++++++++++++-------- 7 files changed, 50 insertions(+), 13 deletions(-) create mode 100644 classes/__init__.py create mode 100644 classes/__pycache__/__init__.cpython-37.pyc create mode 100644 classes/__pycache__/users.cpython-37.pyc create mode 100644 classes/users.py create mode 100644 data/domreshetnikovo@gmail.com/pass.txt create mode 100644 data/osa212@mail.ru/pass.txt diff --git a/classes/__init__.py b/classes/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/classes/__pycache__/__init__.cpython-37.pyc b/classes/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..40ac8bf5cc0f614f390831c4a0ea9371628de39e GIT binary patch literal 149 zcmZ?b<>g`kf&=`o;z0Cc5CH>>K!yVl7qb9~6oz01O-8?!3`HPe1o6vGKeRZts8~NQ zzbLh&Sl=Z-ximL556CJg%Fjwo1~Rg9GV@AO3v%-HlXDV_i&KmB?Zq`?Ot{TT0?Pao#D@Tfq7~6&7bCXv)>?cG|V67ps{?ooGzc51FVnC ztK}5hqgKPr&5?OyUL)W)oF6n0=VF&rM7T&e{IYxk`Pv+s#qyb1m_z5bd;r%4~F=m6pql*)zzh+ L(Fdc+E%N>Y=1_FH literal 0 HcmV?d00001 diff --git a/classes/users.py b/classes/users.py new file mode 100644 index 0000000..55ac2de --- /dev/null +++ b/classes/users.py @@ -0,0 +1,26 @@ +import os + +class Users: + def __init__(self): + self.data = [] + self.path = os.path.join(os.path.abspath('.'), 'data') + + + + + def get_users(self): + self.logins = [] + main_dir = os.walk(self.path) + for d, dirs, files in main_dir: + self.logins.append(dirs) + return self.logins[0] + + def get_passwords(self): + if not os.path.exists(self.path): + return "Папка data не существует. Создайте папку с необходимыми параметрами и запустите программу снова!" + self.emails = self.get_users() + for user in self.emails: + with open(os.path.join(self.path, user, 'pass.txt'), 'r') as f: + log_pass = {'email': user, 'password': f.readline().split('\n')[0]} + self.data.append(log_pass) + return self.data diff --git a/data/domreshetnikovo@gmail.com/pass.txt b/data/domreshetnikovo@gmail.com/pass.txt new file mode 100644 index 0000000..458b6fb --- /dev/null +++ b/data/domreshetnikovo@gmail.com/pass.txt @@ -0,0 +1 @@ +kn2001 diff --git a/data/osa212@mail.ru/pass.txt b/data/osa212@mail.ru/pass.txt new file mode 100644 index 0000000..1e5ee3a --- /dev/null +++ b/data/osa212@mail.ru/pass.txt @@ -0,0 +1 @@ +kn9172 diff --git a/knd_bot.py b/knd_bot.py index b5bc6f0..8297c04 100644 --- a/knd_bot.py +++ b/knd_bot.py @@ -3,6 +3,8 @@ import random import string import json import time +from classes.users import Users + # anwer_text = '{"question_chains":[{"id":6145,"questions":[{"id":6559,"question_components":[{"id":18850,"answer":[80634165],"answer_status":null,"end_time":1591866979,"start_time":1591866978},{"id":18851,"answer":{"location":[56.439337,36.557897]},"answer_status":null,"start_time":1591866873,"end_time":1591867165},{"id":18852,"answer":"1","answer_status":null,"start_time":1591867063,"end_time":1591867063}]}]},{"id":6147,"questions":[{"id":6561,"question_components":[{"id":18856,"answer":77,"answer_status":null,"end_time":1591867067,"start_time":1591867067},{"id":18857,"answer":[80639138],"answer_status":null,"end_time":1591867186,"start_time":1591867185}]}]},{"id":6147,"questions":[{"id":6561,"question_components":[{"id":18856,"answer":77,"answer_status":null,"end_time":1591867200,"start_time":1591867200},{"id":18857,"answer":[80639640],"answer_status":null,"end_time":1591867206,"start_time":1591867205}]}]},{"id":6147,"questions":[{"id":6561,"question_components":[{"id":18856,"answer":77,"answer_status":null,"end_time":1591867211,"start_time":1591867211},{"id":18857,"answer":[80640010],"answer_status":null,"end_time":1591867220,"start_time":1591867219}]}]},{"id":6147,"questions":[{"id":6561,"question_components":[{"id":18856,"answer":77,"answer_status":null,"end_time":1591867223,"start_time":1591867223},{"id":18857,"answer":[80640333],"answer_status":null,"end_time":1591867233,"start_time":1591867232}]}]}]}' @@ -90,19 +92,26 @@ def get_task(session, headers): def main(): - session = requests.Session() - login = { - 'email': 'domreshetnikovo@gmail.com', - 'password': 'kn2001' - } - url = 'https://knd.mosreg.ru//api/v1/auth/sign_in' - response = session.post(url, data=login) - headers = { - 'client': response.headers.get('client'), - 'Access-token': response.headers.get('Access-token'), - 'uid': response.headers.get('uid'), - } - get_task(session, headers) + users = Users() + logins = users.get_passwords() + if isinstance(logins, list): + url = 'https://knd.mosreg.ru//api/v1/auth/sign_in' + for user in logins: + session = requests.Session() + login = { + 'email': user['email'], + 'password': user['password'] + } + response = session.post(url, data=login) + headers = { + 'client': response.headers.get('client'), + 'Access-token': response.headers.get('Access-token'), + 'uid': response.headers.get('uid'), + } + print(headers) + time.sleep(1) + else: + print(users.get_passwords()) if __name__ == "__main__":